Enrico Gullotti
earnest wonderer
earnest wonderer
Geometry
isNumber type-check <Boolean> isNumber <AnyType value> Tests the type of provided argument returning true if it is a number, or false otherwise.
Point2 Vectors Dot Product <Float> dot2 <Point2 p2Vector_1> <Point2 p2Vector_2> Defines dot product for two vectors in 2 dimensions.
Point2 Vectors Cross Product <Point3> cross2 <Point2 p2Vector_1> <Point2 p2Vector_2> Defines cross product for two vectors in 2 dimensions. The result is a vector in the third dimesion.
Get Average Point <Point2> getAveragePoint2 #(<Point2 p2Point>) Computes the average position of a point from an array of positions in 2 dimensions.
<Point3> getAveragePoint #(<Point3 p3Point>)
Computes the average position of a point from an array of positions in 3 dimensions.
Get Vector–Vector Angle <Float> getVectorVectorAngle2 <Point2 p2Vector_1> <Point2 p2Vector_2> [p2Origin:<Point2 default:[0,0]>]Calculates the angle between two vectors. The optional position of a common origin can be provided. Results are in the range [0, 180] degrees.
Required functions: dot2
<Float> getVectorVectorAngle <Point3 p3Vector_1> <Point3 p3Vector_2> [p3Origin:<Point3 default:[0,0,0]>]Calculates the angle between two vectors. The optional position of a common origin can be provided. Results are in the range [0, 180] degrees.
Get Normal–Normal Angle <Float> getNormalNormalAngle2 <Point2 p2Normal_1> <Point2 p2Normal_2>Calculates the angle between two vectors. Results are in the range [0, 180] degrees.
Required functions: dot2
<Float> getNormalNormalAngle <Point3 p3Normal_1> <Point3 p3Normal_2>Calculates the angle between two vectors. Results are in the range [0, 180] degrees.
Get Point–Line Projection <Point2> getPointLineProj2 <Point2 p2Point> <Point2 p2LinePoint_1> <Point2 p2LinePoint_2>Calculates the position of the projection of a point of a plane on a line defined by two points.
Required functions: dot2
<Point3> getPointLineProj <Point3 p3Point> <Point3 p3LinePoint_1> <Point3 p3LinePoint_2> Calculates the position of the projection of a point in space on a line defined by two points.
Get Point–Line Distance <Float> getPointLineDist2 <Point2 p2Point> <Point2 p2LinePoint_1> <Point2 p2LinePoint_2>Calculates the distance of a point of a plane from a line defined by two points.
Required functions: cross2
<Float> getPointLineDist <Point3 p3Point> <Point3 p3LinePoint_1> <Point3 p3LinePoint_2> Calculates the distance of a point in space from a line defined by two points.
Test Point–Line Inclusion <Boolean> isPointOnLine2 <Point2 point> <Point2 p3LinePoint_1> <Point2 p3LinePoint_2> [fEpsilon:<Float default:1E-6>]Tests the inclusion of a point on a plane in a line defined by two points.
Required functions: cross2
<Boolean> isPointOnLine <Point3 point> <Point3 p3LinePoint_1> <Point3 p3LinePoint_2> [fEpsilon:<Float default:1E-6>]
Tests the inclusion of a point in space in a line defined by two points.
Test Point–Segment Inclusion <Boolean> isPointOnSegment <Point3 point> <Point3 p3SegPoint_1> <Point3 p3SegPoint_2> [fEpsilon:<Float default:1E-6>] Tests the inclusion of a point in space in a segment defined by two points.
Get Point along Line <Point3> getPointAlongLine <Point3 p3LinePoint_1> <Point3 p3LinePoint_2> <Float fProp> Calculates the position of a point along a line defined by two points given a proportional factor. Line length is made equal to 1.
Get Point–Plane Projection <Point3> getPointPlaneProj <Point3 p3Point> <Ray rPlane> [fEpsilon:<Float default:1E-6>] Calculates the position of the projection of a point in space on a plane defined by a Ray.
Get Point–Plane Distance <Float> getPointPlaneDist <Point3 p3Point> <Ray rPlane> [bSigned:<Boolean default:false>] [fEpsilon:<Float default:1E-6>] Calculates the distance of a point in space from a line defined by a Ray. Results are in the range [0, 180] degrees. Results are unsigned by default in R+, can optionally be signed in R.
Test Point–Plane Inclusion <Boolean> isPointOnPlane <Point3 p3Point> <Ray rPlane> [fEpsilon:<Float default:1E-6>]Tests the inclusion of a point in space in a plane identified by a Ray.
Get Line–Line Intersection <Point2> getLineLineIntersect2 <Point2 p2Line_1_Point_1> <Point2 p2Line_1_Point_2> <Point2 p2Line_2_Point_1> <Point2 p2Line_2_Point_2> Calculates the point of intersection between two lines defined by two points each. The function returns undefined if intersection point does not exist, when lines are coincident, parallel or skew.
<Point3> getLineLineIntersect <Point3 p3Line_1_Point_1> <Point3 p3Line_1_Point_2> <Point3 p3Line_2_Point_1> <Point3 p3Line_2_Point_2>Calculates the point of intersection between two lines defined by two points each. The function returns undefined if intersection point does not exist, when lines are coincident, parallel or skew.
Get Line–Line Distance <Float> getLineLineDist <Point2 p2Line_1_Point_1> <Point2 p2Line_1_Point_2> <Point2 p2Line_2_Point_1> <Point2 p2Line_2_Point_2> [fEpsilon:<Float default:1E-6>] Calculates the distance between two lines defined by two points each. The function returns undefined when exists an intersection point. Results are unsigned in R.
Required functions: cross2
<Float> getLineLineDist <Point3 p3Line_1_Point_1> <Point3 p3Line_1_Point_2> <Point3 p3Line_2_Point_1> <Point3 p3Line_2_Point_2> [fEpsilon:<Float default:1E-6>] Calculates the distance between two lines defined by two points each. The function returns undefined when exists an intersection point. Results are unsigned in R.
Get Line–Line Angle <Float> getLineLineAngle2 <Point2 p2Line_1_Point_1> <Point2 p2Line_1_Point_2> <Point2 p2Line_2_Point_1> <Point2 p2Line_2_Point_2> [fEpsilon:<Float default:1E-6>]Calculates the angle between two lines defined by two points each. The function returns undefined when lines are skew. Results are in the range [0, 180] degrees.
Required functions: dot2
<Float> getLineLineAngle <Point3 p3Line_1_Point_1> <Point3 p3Line_1_Point_2> <Point3 p3Line_2_Point_1> <Point3 p3Line_2_Point_2> [fEpsilon:<Float default:1E-6>]Calculates the angle between two lines defined by two points each. The function returns undefined when lines are skew. Results are in the range [0, 180] degrees.
Get Line–Plane Intersection <Point3> getLinePlaneIntersect <Point3 p3LinePoint_1> <Point3 p3LinePoint_2> <Ray rPlane> Calculates the intersection point between a line defined by two points and a plane defined by a position and a normal vector. The function returns undefined when line is parallel to plane.
Get Line–Plane Distance <Float> getLinePlaneDist <Point3 p3LinePoint_1> <Point3 p3LinePoint_2> <Ray rPlane> [bSigned:<Boolean default:false>] [fEpsilon:<Float default:1E-6>] Calculates the distance between a line defined by two points and a plane defined by a point and a normal vector. The function returns false when line intersects plane. Results are unsigned by default in R+, can optionally be signed in R.
Get Line–Plane Angle <Point3> getLinePlaneAngle <Point3 p3LinePoint_1> <Point3 p3LinePoint_2> <Ray rPlane> [bSigned:<Boolean default:false>] [fEpsilon:<Float default:1E-6>] Calculates the angle between a line defined by two points and a plane defined by a normal vector. Results are unsigned by default in the range [0, 90] degrees, can optionally be signed in the range [-90, 90] degrees.
Get Plane-Plane Intersection <Point3> getPlanePlaneIntersect <Ray rPlane_1> <Ray rPlane_2> [fEpsilon:<Float default:1E-6>] Calculates the line along the intersection between two planes and returns it as Ray if found.
Get 3 Planes Intersection <Point3> get3PlanesIntersect <Ray rPlane_1> <Ray rPlane_2> <Ray rPlane_3> [fEpsilon:<Float default:1E-6>]Calculates the point of intersection between three planes and returns it as Point3 if found.
Get Bézier Curve Point <Point3> getBezier1 <Point3 p3Point_1> <Point3 p3Point_2> <Float fParam> Calculates the point along a linear Bézier curve by provided parameter. fParam must be in range [0, 1].
<Point3> getBezier2 <Point3 p3Point_1> <Point3 p3Point_2> <Point3 p3Point_3> <Float fParam>
Calculates the point along a quadratic Bézier curve by provided parameter. fParam must be in range [0, 1].
<Point3> getBezier3 <Point3 p3Point_1> <Point3 p3Point_2> <Point3 p3Point_3> <Point3 p3Point_4> <Float fParam>
Calculates the point along a cubic Bézier curve by provided parameter. fParam must be in range [0, 1].
References
- isNumber
- Point2 Dot Product
- Point2 Cross Product
- Average Point
- Vector–Vector Angle
- Normal–Normal Angle
- Point–Line Projection
- Point–Line Distance
- Point along Line
- Point–Line Inclusion
- Point–Segment Inclusion
- Point–Plane Projection
- Point–Plane Distance
- Point–Plane Inclusion
- Line–Line Intersection
- Line–Line Distance
- Line–Line Angle
- Line–Plane Intersection
- Line–Plane Distance
- Line–Plane Angle
- Plane–Plane Intersection
- 3 Planes Intersection
- Bézier Curve Point
isNumber type-check <Boolean> isNumber <AnyType value> Tests the type of provided argument returning true if it is a number, or false otherwise.
function isNumber inValue = ( local resultTest = false if ((classOf inValue) == Float) then return true else if ((classOf inValue) == Integer) then return true else if ((classOf inValue) == Double) then return true else if ((classOf inValue) == Integer64) then return true else if ((classOf inValue) == IntegerPtr) then return true else return false )
Point2 Vectors Dot Product <Float> dot2 <Point2 p2Vector_1> <Point2 p2Vector_2> Defines dot product for two vectors in 2 dimensions.
function dot2 &p2Vector_1 &p2Vector_2 = ( return (p2Vector_1.x * p2Vector_2.x + p2Vector_1.y * p2Vector_2.y) )
Point2 Vectors Cross Product <Point3> cross2 <Point2 p2Vector_1> <Point2 p2Vector_2> Defines cross product for two vectors in 2 dimensions. The result is a vector in the third dimesion.
function cross2 &p2Vector_1 &p2Vector_2 = ( return [0.0, 0.0, p2Vector_1.x * p2Vector_2.y - p2Vector_1.y * p2Vector_2.x] )
Get Average Point <Point2> getAveragePoint2 #(<Point2 p2Point>) Computes the average position of a point from an array of positions in 2 dimensions.
function getAveragePoint2 &afInput = ( local fAvgValue = 0.0 for fValue in afInput do fAvgValue += fValue fAvgValue /= afInput.count return fAvgValue )
function getAveragePoint &ap3Input = ( local p3AvgPos = [0,0,0] for p3Pos in ap3Input do p3AvgPos += p3Pos p3AvgPos /= ap3Input.count return p3AvgPos )
Get Vector–Vector Angle <Float> getVectorVectorAngle2 <Point2 p2Vector_1> <Point2 p2Vector_2> [p2Origin:<Point2 default:[0,0]>]Calculates the angle between two vectors. The optional position of a common origin can be provided. Results are in the range [0, 180] degrees.
Required functions: dot2
function getVectorVectorAngle2 &p2Vector_1 &p2Vector_2 &p2Origin:[0,0] = ( return (acos (dot2 (normalize (p2Vector_1 - p2Origin)) (normalize (p2Vector_2 - p2Origin)))) )
function getVectorVectorAngle &p3Vector_1 &p3Vector_2 &p3Origin:[0,0,0] =
(
return (acos (dot (normalize (p3Vector_1 - p3Origin)) (normalize (p3Vector_2 - p3Origin))))
)
Get Normal–Normal Angle <Float> getNormalNormalAngle2 <Point2 p2Normal_1> <Point2 p2Normal_2>Calculates the angle between two vectors. Results are in the range [0, 180] degrees.
Required functions: dot2
function getNormalNormalAngle2 &p2Normal_1 &p2Normal_2 = ( return (acos (dot2 p2Normal_1 p2Normal_1)) )
function getNormalNormalAngle &p3Normal_1 &p3Normal_2 = ( return (acos (dot p3Normal_1 p3Normal_1)) )
Get Point–Line Projection <Point2> getPointLineProj2 <Point2 p2Point> <Point2 p2LinePoint_1> <Point2 p2LinePoint_2>Calculates the position of the projection of a point of a plane on a line defined by two points.
Required functions: dot2
function getPointLineProj2 &p2Point &p2LinePoint_1 &p2LinePoint_2 = ( local p2LineNormalDir = normalize (p2LinePoint_2 - p2LinePoint_1) local p2PointVector = p2Point - p2LinePoint_1 return (p2LinePoint_1 + (p2LineNormalDir * (dot2 p2PointVector p2LineNormalDir))) )
function getPointLineProj &p3Point &p3LinePoint_1 &p3LinePoint_2 = ( local p3LineNormalDir = normalize (p3LinePoint_2 - p3LinePoint_1) local p3PointVector = p3Point - p3LinePoint_1 return (p3LinePoint_1 + (p3LineNormalDir * (dot p3PointVector p3LineNormalDir))) )
Get Point–Line Distance <Float> getPointLineDist2 <Point2 p2Point> <Point2 p2LinePoint_1> <Point2 p2LinePoint_2>Calculates the distance of a point of a plane from a line defined by two points.
Required functions: cross2
function getPointLineDist2 &p2Point &p2LinePoint_1 &p2LinePoint_2 = ( local p2LineNormalDir = normalize (p2LinePoint_2 - p2LinePoint_1) local p2PointVector = p2Point - p2LinePoint_1 return (length (cross2 p2PointVector p2LineNormalDir)) )
function getPointLineDist &p3Point &p3LinePoint_1 &p3LinePoint_2 = ( local p3LineNormalDir = normalize (p3LinePoint_2 - p3LinePoint_1) local p3PointVector = p3Point - p3LinePoint_1 return (length (cross p3PointVector p3LineNormalDir)) )
Test Point–Line Inclusion <Boolean> isPointOnLine2 <Point2 point> <Point2 p3LinePoint_1> <Point2 p3LinePoint_2> [fEpsilon:<Float default:1E-6>]Tests the inclusion of a point on a plane in a line defined by two points.
Required functions: cross2
function isPointOnLine2 &p2Point &p2LinePoint_1 &p2LinePoint_2 fEpsilon:1E-6 = ( local p2LineNormalDir = normalize (p2LinePoint_2 - p2LinePoint_1) local p2PointNormalVector = normalize (p2Point - p2LinePoint_1) return ((length (cross2 p2LineNormalDir p2PointNormalVector)) <= fEpsilon) )
function isPointOnLine &p3Point &p3LinePoint_1 &p3LinePoint_2 fEpsilon:1E-6 = ( local p3LineNormalDir = normalize (p3LinePoint_2 - p3LinePoint_1) local p3PointNormalVector = normalize (p3Point - p3LinePoint_1) return ((length (cross p3LineNormalDir p3PointNormalVector)) <= fEpsilon) )
Test Point–Segment Inclusion <Boolean> isPointOnSegment <Point3 point> <Point3 p3SegPoint_1> <Point3 p3SegPoint_2> [fEpsilon:<Float default:1E-6>] Tests the inclusion of a point in space in a segment defined by two points.
function isPointOnSegment &p3Point &p3SegPoint_1 &p3SegPoint_2 fEpsilon:1E-6 = ( local fSegLength = distance p3SegPoint_1 p3SegPoint_2 local fDist_1 = distance p3Point p3SegPoint_1 local fDist_2 = distance p3Point p3SegPoint_2 return (((fDist_1 + fDist_2) - fSegLength) <= fEpsilon) )
Get Point along Line <Point3> getPointAlongLine <Point3 p3LinePoint_1> <Point3 p3LinePoint_2> <Float fProp> Calculates the position of a point along a line defined by two points given a proportional factor. Line length is made equal to 1.
function getPointAlongLine &p3LinePoint_1 &p3LinePoint_2 fProp = ( return (p3LinePoint_1 + (p3LinePoint_2 - p3LinePoint_1) * fProp) )
Get Point–Plane Projection <Point3> getPointPlaneProj <Point3 p3Point> <Ray rPlane> [fEpsilon:<Float default:1E-6>] Calculates the position of the projection of a point in space on a plane defined by a Ray.
function getPointPlaneProj &p3Point &rPlane fEpsilon:1E-6 = ( local p3PointVector = p3Point - rPlane.pos local p3Cross_1 = cross p3PointVector rPlane.dir local p3Cross_2 = cross rPlane.dir p3Cross_1 if ((length p3Cross_1) <= fEpsilon) then return rPlane.pos else return (rPlane.pos + p3Cross_2) )
Get Point–Plane Distance <Float> getPointPlaneDist <Point3 p3Point> <Ray rPlane> [bSigned:<Boolean default:false>] [fEpsilon:<Float default:1E-6>] Calculates the distance of a point in space from a line defined by a Ray. Results are in the range [0, 180] degrees. Results are unsigned by default in R+, can optionally be signed in R.
function getPointPlaneDist &p3Point &rPlane bSigned:false fEpsilon:1E-6 = ( local p3PointVector = p3Point - rPlane.pos local p3Cross_1 = cross p3PointVector rPlane.dir local p3Cross_2 = cross rPlane.dir p3Cross_1 local fDist = 0.0 if ((length p3Cross_1) >= fEpsilon) then fDist = length (cross p3PointVector (normalize p3Cross_2)) else fDist = length p3PointVector if ( (bSigned == true) and ((dot p3PointVector rPlane.dir) < 0.0) ) do fDist = -fDist return fDist )
Test Point–Plane Inclusion <Boolean> isPointOnPlane <Point3 p3Point> <Ray rPlane> [fEpsilon:<Float default:1E-6>]Tests the inclusion of a point in space in a plane identified by a Ray.
function isPointOnPlane &p3Point &rPlane fEpsilon:1E-6 = ( local p3PointVector = p3Point - rPlane.pos local p3Cross_1 = cross p3PointVector rPlane.dir local p3Cross_2 = cross rPlane.dir p3Cross_1 return ((length (cross (normalize p3PointVector) (normalize p3Cross_2) )) <= fEpsilon) )
Get Line–Line Intersection <Point2> getLineLineIntersect2 <Point2 p2Line_1_Point_1> <Point2 p2Line_1_Point_2> <Point2 p2Line_2_Point_1> <Point2 p2Line_2_Point_2> Calculates the point of intersection between two lines defined by two points each. The function returns undefined if intersection point does not exist, when lines are coincident, parallel or skew.
function getLineLineIntersect2 &p2Line_1_Point_1 &p2Line_1_Point_2 &p2Line_2_Point_1 &p2Line_2_Point_2 = ( local p2Vector_A = p2Line_1_Point_2 - p2Line_1_Point_1 local p2Vector_B = p2Line_2_Point_2 - p2Line_2_Point_1 local p2Vector_C = p2Line_1_Point_1 - p2Line_2_Point_1 local fDenom = (p2Vector_A.y * p2Vector_B.x) - (p2Vector_A.x * p2Vector_B.y) local fNumer = (p2Vector_B.y * p2Vector_C.x) - (p2Vector_B.x * p2Vector_C.y) if ( (fNumer == 0.0) and (fDenom == 0.0) ) then -- coincident return undefined else if ( (fNumer != 0.0) and (fDenom == 0.0) ) then -- parallel return undefined else -- intersecting return (p2Line_1_Point_1 + ((fNumer / fDenom) * p2Vector_A)) )
function getLineLineIntersect &p3Line_1_Point_1 &p3Line_1_Point_2 &p3Line_2_Point_1 &p3Line_2_Point_2 fEpsilon:1E-6 = ( local p3Vector_A = p3Line_1_Point_2 - p3Line_1_Point_1 local p3Vector_B = p3Line_2_Point_2 - p3Line_2_Point_1 local p3Vector_C = p3Line_1_Point_1 - p3Line_2_Point_1 local p3Cross_AB = cross p3Vector_A p3Vector_B if ( (abs (dot p3Vector_C p3Cross_AB)) >= fEpsilon) then -- skew return undefined else if ( ((length (cross (normalize p3Vector_A) (normalize p3Vector_C))) <= fEpsilon) and \ ((length (cross (normalize p3Vector_B) (normalize p3Vector_C))) <= fEpsilon) ) then -- coincident return undefined else if (length (p3Cross_AB) <= fEpsilon) then -- parallel return undefined else -- intersecting return (p3Line_1_Point_1 + (p3Vector_A * (dot (cross p3Vector_C p3Vector_B) p3Cross_AB) / ((length p3Cross_AB)^2))) )
Get Line–Line Distance <Float> getLineLineDist <Point2 p2Line_1_Point_1> <Point2 p2Line_1_Point_2> <Point2 p2Line_2_Point_1> <Point2 p2Line_2_Point_2> [fEpsilon:<Float default:1E-6>] Calculates the distance between two lines defined by two points each. The function returns undefined when exists an intersection point. Results are unsigned in R.
Required functions: cross2
function getLineLineDist2 &p2Line_1_Point_1 &p2Line_1_Point_2 &p2Line_2_Point_1 &p2Line_2_Point_2 = ( local p2Vector_A = p2Line_1_Point_2 - p2Line_1_Point_1 local p2Vector_B = p2Line_2_Point_2 - p2Line_2_Point_1 local p2Vector_C = p2Line_1_Point_1 - p2Line_2_Point_1 local fDenom = (p2Vector_A.y * p2Vector_B.x) - (p2Vector_A.x * p2Vector_B.y) local fNumer = (p2Vector_B.y * p2Vector_C.x) - (p2Vector_B.x * p2Vector_C.y) if ( (fNumer == 0.0) and (fDenom == 0.0) ) then -- coincident return 0.0 else if ( (fNumer != 0.0) and (fDenom == 0.0) ) then -- parallel return (length (cross2 p2Vector_C (normalize p2Vector_A))) else -- intersecting return undefined )
function getLineLineDist &p3Line_1_Point_1 &p3Line_1_Point_2 &p3Line_2_Point_1 &p3Line_2_Point_2 fEpsilon:1E-6 = ( local p3Vector_A = p3Line_1_Point_2 - p3Line_1_Point_1 local p3Vector_B = p3Line_2_Point_2 - p3Line_2_Point_1 local p3Vector_C = p3Line_1_Point_1 - p3Line_2_Point_1 local p3Cross_AB = cross p3Vector_A p3Vector_B if ((abs (dot p3Vector_C p3Cross_AB)) >= fEpsilon) then -- skew return (abs (dot p3Vector_C (normalize p3Cross_AB))) else if ( ((length (cross p3Vector_A p3Vector_C)) <= fEpsilon) and \ ((length (cross p3Vector_B p3Vector_C)) <= fEpsilon) ) then -- coincident return 0.0 else if ((length p3Cross_AB) <= fEpsilon) then -- parallel return (abs (dot p3Vector_C (normalize p3Cross_AB))) else -- intersecting return undefined )
Get Line–Line Angle <Float> getLineLineAngle2 <Point2 p2Line_1_Point_1> <Point2 p2Line_1_Point_2> <Point2 p2Line_2_Point_1> <Point2 p2Line_2_Point_2> [fEpsilon:<Float default:1E-6>]Calculates the angle between two lines defined by two points each. The function returns undefined when lines are skew. Results are in the range [0, 180] degrees.
Required functions: dot2
function getLineLineAngle2 &p2Line_1_Point_1 &p2Line_1_Point_2 &p2Line_2_Point_1 &p2Line_2_Point_2 = ( local p2Vector_A = p2Line_1_Point_2 - p2Line_1_Point_1 local p2Vector_B = p2Line_2_Point_2 - p2Line_2_Point_1 local p2Vector_C = p2Line_1_Point_1 - p2Line_2_Point_1 local fDenom = (p2Vector_A.y * p2Vector_B.x) - (p2Vector_A.x * p2Vector_B.y) local fNumer_1 = (p2Vector_B.y * p2Vector_C.x) - (p2Vector_B.x * p2Vector_C.y) if ( (fNumer_1 == 0.0) and (fDenom == 0.0) ) then -- coincident return 0.0 else if ( (fNumer_1 != 0.0) and (fDenom == 0.0) ) then -- parallel return 0.0 else -- intersecting return (acos (dot2 (normalize p2Vector_A) (normalize p2Vector_B))) )
function getLineLineAngle &p3Line_1_Point_1 &p3Line_1_Point_2 &p3Line_2_Point_1 &p3Line_2_Point_2 fEpsilon:1E-6 = ( local p3Vector_A = p3Line_1_Point_2 - p3Line_1_Point_1 local p3Vector_B = p3Line_2_Point_2 - p3Line_2_Point_1 local p3Vector_C = p3Line_1_Point_1 - p3Line_2_Point_1 local p3Cross_AB = cross p3Vector_A p3Vector_B if ((abs (dot p3Vector_C p3Cross_AB)) >= fEpsilon) then -- skew return undefined else if ( ((length (cross p3Vector_A p3Vector_C)) <= fEpsilon) and \ ((length (cross p3Vector_B p3Vector_C)) <= fEpsilon) ) then -- coincident return 0.0 else if ((length p3Cross_AB) <= fEpsilon) then -- parallel return 0.0 else -- intersecting return (acos (dot (normalize p3Vector_A) (normalize p3Vector_B))) )
Get Line–Plane Intersection <Point3> getLinePlaneIntersect <Point3 p3LinePoint_1> <Point3 p3LinePoint_2> <Ray rPlane> Calculates the intersection point between a line defined by two points and a plane defined by a position and a normal vector. The function returns undefined when line is parallel to plane.
function getLinePlaneIntersect &p3LinePoint_1 &p3LinePoint_2 &rPlane fEpsilon:1E-6 = ( local p3LineVector = p3LinePoint_2 - p3LinePoint_1 local p3Vector_1 = planePos - p3LinePoint_1 local fNumer = dot rPlane.dir p3Vector_1 local fDenom = dot rPlane.dir p3LineVector if ((abs fDenom) >= fEpsilon) then -- line intersects plane return (p3LinePoint_1 + ((fNumer / fDenom) * p3LineVector)) else -- line is parallel to plane return undefined )
Get Line–Plane Distance <Float> getLinePlaneDist <Point3 p3LinePoint_1> <Point3 p3LinePoint_2> <Ray rPlane> [bSigned:<Boolean default:false>] [fEpsilon:<Float default:1E-6>] Calculates the distance between a line defined by two points and a plane defined by a point and a normal vector. The function returns false when line intersects plane. Results are unsigned by default in R+, can optionally be signed in R.
function getLinePlaneDist &p3LinePoint_1 &p3LinePoint_2 &rPlane bSigned:false fEpsilon:1E-6 = ( local p3LineVector = p3LinePoint_2 - p3LinePoint_1 local p3Vector_1 = p3LinePoint_1 - rPlane.pos local p3Cross_1 = cross p3Vector_1 planeDir local p3Cross_2 = cross rPlane.dir p3Cross_1 if ((dot p3LineVector rPlane.dir) <= fEpsilon) then -- line is parallel to plane ( local fDist = length (cross p3Vector_1 (normalize p3Cross_2)) if ( (bSigned == true) and ((dot p3Vector_1 planeDir) < 0.0) ) do fDist = -fDist return fDist ) else -- line intersects plane ( return undefined ) )
Get Line–Plane Angle <Point3> getLinePlaneAngle <Point3 p3LinePoint_1> <Point3 p3LinePoint_2> <Ray rPlane> [bSigned:<Boolean default:false>] [fEpsilon:<Float default:1E-6>] Calculates the angle between a line defined by two points and a plane defined by a normal vector. Results are unsigned by default in the range [0, 90] degrees, can optionally be signed in the range [-90, 90] degrees.
function getLinePlaneAngle &p3LinePoint_1 &p3LinePoint_2 &rPlane bSigned:false fEpsilon:1E-6 = ( local p3LineNormalDir = normalize (p3LinePoint_2 - p3LinePoint_1) local fTest = length (cross p3LineNormalDir rPlane.dir) if ( (fTest <= -fEpsilon) or (fTest >= fEpsilon) ) then -- line intersects plane ( local fAngle = 90.0 - (acos (dot p3LineNormalDir rPlane.dir)) if (bSigned == false) do fAngle = abs fAngle return fAngle ) else -- line is perpendicular to plane ( if ((dot p3LineNormalDir planeNorm) < 0.0) then return (-90.0) else return 90.0 ) )
Get Plane-Plane Intersection <Point3> getPlanePlaneIntersect <Ray rPlane_1> <Ray rPlane_2> [fEpsilon:<Float default:1E-6>] Calculates the line along the intersection between two planes and returns it as Ray if found.
function getPlanePlaneIntersect &rPlane_1 &rPlane_2 fEpsilon:1E-6 = ( local d1 = dot rPlane_1.pos rPlane_1.dir local d2 = dot rPlane_2.pos rPlane_2.dir local d3 = dot rPlane_1.dir rPlane_2.dir if ((abs d3) < (1-fEpsilon)) then return (Ray ( (((d2*d3) + d1) / (1-(d3^2))) * rPlane_1.dir + (((d1*d3) + d2) / (1-(d3^2))) * rPlane_2.dir) (cross rPlane_1.dir rPlane_2.dir) ) else return undefined )
Get 3 Planes Intersection <Point3> get3PlanesIntersect <Ray rPlane_1> <Ray rPlane_2> <Ray rPlane_3> [fEpsilon:<Float default:1E-6>]Calculates the point of intersection between three planes and returns it as Point3 if found.
function get3PlanesIntersect &rPlane_1 &rPlane_2 &rPlane_3 fEpsilon:1E-6 = ( local d1 = dot rPlane_1.pos rPlane_1.dir local d2 = dot rPlane_2.pos rPlane_2.dir local d3 = dot rPlane_3.pos rPlane_3.dir local c1 = cross rPlane_2.dir rPlane_3.dir local c2 = cross rPlane_3.dir rPlane_1.dir local c3 = cross rPlane_1.dir rPlane_2.dir local fDenom = dot rPlane_1.dir c1 if ((abs fDenom) > fEpsilon) then return ( ((d1*c1) + (d2*c2) + (d3*c3)) / fDenom ) else return undefined )
Get Bézier Curve Point <Point3> getBezier1 <Point3 p3Point_1> <Point3 p3Point_2> <Float fParam> Calculates the point along a linear Bézier curve by provided parameter. fParam must be in range [0, 1].
function getBezier1 &p3Point_1 &p3Point_2 fParam = ( return ( ((1-fParam) * p3Point_1) + (fParam*p3Point_2) ) )
function getBezier2 &p3Point_1 &p3Point_2 &p3Point_3 fParam = ( return ( (((1-fParam)^2) * p3Point_1) + (2 * (1-fParam) * fParam * p3Point_2) + ((fParam^2) * p3Point_3) ) )
function getBezier3 &p3Point_1 &p3Point_2 &p3Point_3 &p3Point_4 fParam = ( return ( (((1-fParam)^3) * p3Point_1) + (3 * ((1-fParam)^2) * fParam * p3Point_2) + (3 * (1-fParam) * (fParam^2) * p3Point_3) + ((fParam^3) * p3Point_4) ) )