ConvexHull.kl

Types

Vec2 (struct)

The Vec2 type represents a vector with 2 components. The Vec2 is also used as the row type for the Mat22.

参考

Vec3, Vec4

/*
** Example: Vec2
*/

Vec2 v(0.0, 0.0);

Members

Scalar x  
Scalar y  

Methods

  Vec2 ( in Scalar value )
  Vec2 ( in Scalar x, in Scalar y )
  Vec2 ( in Vec2 other )
  Vec2 ()
Vec2 add ? ( in Vec2 other )
Boolean almostEqual ? ( in Vec2 other )
Boolean almostEqual ? ( in Vec2 other, in Scalar precision )
Scalar angleTo ? ( in Vec2 other )
Vec2 clamp ? ( in Vec2 min, in Vec2 max )
Vec2 clone ? ()
Scalar component ? ( in Size i )
Scalar cross ? ( in Vec2 other )
Scalar distanceTo ? ( in Vec2 other )
Scalar distanceToLine ? ( in Vec2 lineP0, in Vec2 lineP1 )
Scalar distanceToSegment ? ( in Vec2 segmentP0, in Vec2 segmentP1 )
Vec2 divide ? ( in Vec2 other )
Vec2 divideScalar ? ( in Scalar other )
Scalar dot ? ( in Vec2 other )
Boolean equal ? ( in Vec2 other )
  get ? ( io Float32 v<> )
  get ? ( io Float32 v<>, in UInt32 o )
  get ? ( io Float32 v[] )
  get ? ( io Float32 v[], in UInt32 o )
  get ? ( io Float64 v<> )
  get ? ( io Float64 v<>, in UInt32 o )
  get ? ( io Float64 v[] )
  get ? ( io Float64 v[], in UInt32 o )
Vec2 getBarycentricCoords ? ( in Vec2 a, in Vec2 b, in Vec2 c )
UInt32 hash ? ()
Vec2 inverse ? ()
Boolean isInsideTriangle ? ( in Vec2 a, in Vec2 b, in Vec2 c )
Boolean isInsideTriangle ? ( in Vec2 a, in Vec2 b, in Vec2 c, in Scalar tolerance )
Scalar length ? ()
Scalar lengthSquared ? ()
Vec2 linearInterpolate ? ( in Vec2 other, in Scalar t )
Vec2 multiply ? ( in Vec2 other )
Vec2 multiplyScalar ? ( in Scalar other )
Vec2 negate ? ()
  normalize ! ()
Vec2 rotate ? ( in Scalar radians )
  set ! ( in Float32 v<> )
  set ! ( in Float32 v<>, in UInt32 o )
  set ! ( in Float64 v<> )
  set ! ( in Float64 v<>, in UInt32 o )
  set ! ( in Scalar value )
  set ! ( in Scalar x, in Scalar y )
  setComponent ! ( in Size i, in Scalar v )
  setNull ! ()
Scalar setUnit ! ()
Vec2 subtract ? ( in Vec2 other )
Vec2 unit ? ()
Vec2 unit_safe ? ()
Scalar unitsAngleTo ? ( in Vec2 other )

Operators

  - Vec2
Vec2 = ( Param other )

Functions

checkTriangleOverlap

Boolean checkTriangleOverlap ( in Vec2 a0, in Vec2 a1, in Vec2 a2, in Vec2 b0, in Vec2 b1, in Vec2 b2, in Scalar tolerance )

returns true if two triangles formed by a0, a1, a2 and b0, b1, b2 overlap given a tolerance distance.

getConvexHull

Vec2[] getConvexHull ( in Vec2 points[] )

Returns the counter clockwise convex hull for an array of Vec2 This uses the Graham Scan algorithm

getMinimumBoundingRectangle

getMinimumBoundingRectangle ( in Vec2 points[], out Vec2 center, out Vec2 dimensions, out Scalar rotation )

Returns the smallest surrounding rectangle as the center of the rectangle, it’s dimensions and a rotation angle.