geo Class
Computational geometry algorithms, is a static class
Item Index
Methods
- createPlane
- distance2PointToPlane
- distancePointToPlane
- extractPlanes
- frustumTestBox
- frustumTestSphere
- project2DPointOnLine
- projectPointOnLine
- projectPointOnPlane
- reflectPointInPlane
- testBBoxBBox
- testPoint2DInPolygon
- testPointBBox
- testRayBBox
- testRayBox
- testRayCylinder
- testRayPlane
- testRaySphere
- testSegmentPlane
- testSphereBBox
Methods
createPlane
-
P -
N
Returns a float4 containing the info about a plane with normal N and that passes through point P
Parameters:
-
PVec3 -
NVec3
Returns:
plane values
distance2PointToPlane
-
point -
plane
Computes the square distance between the point and the plane
Parameters:
-
pointVec3 -
planeVec4
Returns:
distance*distance
distancePointToPlane
-
point -
plane
Computes the distance between the point and the plane
Parameters:
-
pointVec3 -
planeVec4
Returns:
distance
extractPlanes
-
viewprojection
extract frustum planes given a view-projection matrix
Parameters:
-
viewprojectionMat4matrix
Returns:
returns all 6 planes in a float32array[24]
frustumTestBox
-
planes -
boundindbox
test a BBox against the frustum
Parameters:
-
planesFloat32Arrayfrustum planes
-
boundindboxBBoxin BBox format
Returns:
CLIP_INSIDE, CLIP_OVERLAP, CLIP_OUTSIDE
frustumTestSphere
-
center -
radius
test a Sphere against the frustum
Parameters:
-
centerVec3sphere center
-
radiusNumbersphere radius
Returns:
CLIP_INSIDE, CLIP_OVERLAP, CLIP_OUTSIDE
project2DPointOnLine
-
P -
A -
B -
result
Projects a 2D point on a 2D line
Parameters:
-
PVec2 -
AVec2line start
-
BVec2line end
-
resultVec2to store result (optional)
Returns:
projectec point
projectPointOnLine
-
P -
A -
B -
result
Projects a 3D point on a 3D line
Parameters:
-
PVec3 -
AVec3line start
-
BVec3line end
-
resultVec3to store result (optional)
Returns:
projectec point
projectPointOnPlane
-
point -
P -
N -
result
Projects point on plane
Parameters:
-
pointVec3 -
PVec3plane point
-
NVec3plane normal
-
resultVec3to store result (optional)
Returns:
projectec point
reflectPointInPlane
-
point -
P -
N
Finds the reflected point over a plane (useful for reflecting camera position when rendering reflections)
Parameters:
-
pointVec3point to reflect
-
PVec3point where the plane passes
-
NVec3normal of the plane
Returns:
reflected point
testBBoxBBox
-
a -
b
test if a BBox overlaps another BBox
Returns:
true if it overlaps
testPoint2DInPolygon
-
poly -
point
test if a 2d point is inside a 2d polygon
Parameters:
-
polyArrayarray of 2d points
-
pointVec2
Returns:
true if it is inside
testPointBBox
-
point -
bbox
test if a 3d point is inside a BBox
Parameters:
-
pointVec3 -
bboxBBox
Returns:
true if it is inside
testRayBBox
-
origin -
direction -
box -
model -
result
test a ray bounding-box collision, it uses the BBox class and allows to use non-axis aligned bbox
Parameters:
-
originVec3ray origin
-
directionVec3ray direction
-
boxBBoxin BBox format
-
modelMat4transformation of the BBox [optional]
-
resultVec3collision position in world space unless in_local is true
Returns:
returns if the ray collides the box
testRayBox
-
start -
direction -
minB -
maxB -
result
test a ray bounding-box collision and retrieves the collision point, the BB must be Axis Aligned
Parameters:
-
startVec3ray start
-
directionVec3ray direction
-
minBVec3minimum position of the bounding box
-
maxBVec3maximim position of the bounding box
-
resultVec3collision position
Returns:
returns if the ray collides the box
testRayCylinder
-
start -
direction -
p -
q -
r -
result
test a ray cylinder collision (only vertical cylinders) and retrieves the collision point [not fully tested]
Parameters:
-
startVec3ray start
-
directionVec3ray direction
-
pVec3center of the cylinder
-
qNumberheight of the cylinder
-
rNumberradius of the cylinder
-
resultVec3collision position
Returns:
returns if the ray collides the cylinder
testRayPlane
-
start -
direction -
P -
N -
result
test a ray plane collision and retrieves the collision point
Parameters:
-
startVec3ray start
-
directionVec3ray direction
-
PVec3point where the plane passes
-
NVec3normal of the plane
-
resultVec3collision position
Returns:
returns if the ray collides the plane or the ray is parallel to the plane
testRaySphere
-
start -
direction -
center -
radius -
result -
max_dist
test a ray sphere collision and retrieves the collision point
Parameters:
-
startVec3ray start
-
directionVec3ray direction (normalized)
-
centerVec3center of the sphere
-
radiusNumberradius of the sphere
-
resultVec3[optional] collision position
-
max_distNumbernot fully tested
Returns:
returns if the ray collides the sphere
testSegmentPlane
-
start -
end -
P -
N -
result
test collision between segment and plane and retrieves the collision point
Parameters:
-
startVec3segment start
-
endVec3segment end
-
PVec3point where the plane passes
-
NVec3normal of the plane
-
resultVec3collision position
Returns:
returns if the segment collides the plane or it is parallel to the plane
testSphereBBox
-
point -
radius -
bounding_box
test if a sphere overlaps a BBox
Parameters:
-
pointVec3 -
radiusFloat -
bounding_boxBBox
Returns:
true if it overlaps
