KiCad PCB EDA Suite
ttl_util Namespace Reference

Utilities. More...

Functions

Computational geometry
template<class REAL_TYPE >
REAL_TYPE ScalarProduct2D (REAL_TYPE aDX1, REAL_TYPE aDY1, REAL_TYPE aDX2, REAL_TYPE aDY2)
 Scalar product between two 2D vectors. More...
 
template<class REAL_TYPE >
REAL_TYPE CrossProduct2D (REAL_TYPE aDX1, REAL_TYPE aDY1, REAL_TYPE aDX2, REAL_TYPE aDY2)
 Cross product between two 2D vectors. More...
 
template<class REAL_TYPE >
REAL_TYPE Orient2DFast (REAL_TYPE aPA[2], REAL_TYPE aPB[2], REAL_TYPE aPC[2])
 Returns a positive value if the 2D nodes/points aPA, aPB, and aPC occur in counterclockwise order; a negative value if they occur in clockwise order; and zero if they are collinear. More...
 

Detailed Description

Utilities.

This name saPAce contains utility functions for TTL.
Point and vector algebra such as scalar product and cross product between vectors are implemented here. These functions are required by functions in the ttl namesaPAce, where they are assumed to be present in the TTLtraits class. Thus, the user can call these functions from the traits class. For efficiency reasons, the user may consider implementing these functions in the the API directly on the actual data structure; see api.

Note
  • Cross product between vectors in the xy-plane delivers a scalar, which is the z-component of the actual cross product (the x and y components are both zero).
See also
ttl and api
Author
´┐Żyvind Hjelle, oyvin.nosp@m.dhj@.nosp@m.ifi.u.nosp@m.io.n.nosp@m.o

Function Documentation

template<class REAL_TYPE >
REAL_TYPE ttl_util::CrossProduct2D ( REAL_TYPE  aDX1,
REAL_TYPE  aDY1,
REAL_TYPE  aDX2,
REAL_TYPE  aDY2 
)

Cross product between two 2D vectors.

(The z-component of the actual cross product.)

Returns:

aDX1*aDY2 - aDY1*aDX2

Definition at line 102 of file ttl_util.h.

Referenced by ttl::TRIANGULATION_HELPER::ConvexBoundary(), hed::TTLtraits::CrossProduct2D(), ttl::TRIANGULATION_HELPER::degenerateTriangle(), ttl::TRIANGULATION_HELPER::InTriangle(), ttl::TRIANGULATION_HELPER::SwappableEdge(), and ttl::TRIANGULATION_HELPER::SwapTestDelaunay().

103 {
104  return aDX1 * aDY2 - aDY1 * aDX2;
105 }
template<class REAL_TYPE >
REAL_TYPE ttl_util::Orient2DFast ( REAL_TYPE  aPA[2],
REAL_TYPE  aPB[2],
REAL_TYPE  aPC[2] 
)

Returns a positive value if the 2D nodes/points aPA, aPB, and aPC occur in counterclockwise order; a negative value if they occur in clockwise order; and zero if they are collinear.

Note

Definition at line 117 of file ttl_util.h.

Referenced by hed::TTLtraits::Orient2D().

118 {
119  REAL_TYPE acx = aPA[0] - aPC[0];
120  REAL_TYPE bcx = aPB[0] - aPC[0];
121  REAL_TYPE acy = aPA[1] - aPC[1];
122  REAL_TYPE bcy = aPB[1] - aPC[1];
123 
124  return acx * bcy - acy * bcx;
125 }
template<class REAL_TYPE >
REAL_TYPE ttl_util::ScalarProduct2D ( REAL_TYPE  aDX1,
REAL_TYPE  aDY1,
REAL_TYPE  aDX2,
REAL_TYPE  aDY2 
)

Scalar product between two 2D vectors.

Returns:

aDX1*aDX2 + aDY1*aDY2

Definition at line 89 of file ttl_util.h.

Referenced by ttl::TRIANGULATION_HELPER::InTriangle(), hed::TTLtraits::ScalarProduct2D(), and ttl::TRIANGULATION_HELPER::SwapTestDelaunay().

90 {
91  return aDX1 * aDX2 + aDY1 * aDY2;
92 }