Geometry Extension’s Free Functions

Boolean BBoxContains ( in Vec3 min, in Vec3 max, in Vec3 point )

Returns true if point is in or on the box formed by min and max


EvaluateNurbsBasis ( in UInt8 order, in Float32 knots<>, in Float32 t, io Float32 N<> )

Translation of OpenNURBS’s ON_EvaluateNurbsBasis (simplified).

Modification: - t_k and k_t use the last entries of N, so N is expected to be of size order*(order+2) instead of size order*order. - We assume N to be already zeroed (KL initializes memory)

Evaluate B-spline basis functions

INPUT: order >= 1 d = degree = order - 1 knot[] array of length 2*d. Generally, knot[0] <= ... <= knot[d-1] < knot[d] <= ... <= knot[2*d-1]. N[] array of length order*order

OUTPUT: If “N” were declared as double N[order][order], then

k N[d-k][i] = N (t) = value of i-th degree k basis function. i where 0 <= k <= d and k <= i <= d.

In particular, N[0], ..., N[d] - values of degree d basis functions. The “lower left” triangle is not initialized.

Actually, the above is true when knot[d-1] <= t < knot[d]. Otherwise, the value returned is the value of the polynomial that agrees with N_i^k on the half open domain [ knot[d-1], knot[d] )


EvaluateNurbsBasisDerivatives ( in UInt8 order, in Boolean implicitKnots, in UInt32 implicitKnots_minSpanIndex, in UInt32 implicitKnots_maxSpanIndex, in Float32 knots<>, in UInt8 der_count, io Float32 N<>, io Float32 dkArr<> )


EvaluateNurbsBasis_uniformKnots ( in UInt8 order, in Float32 t, in SInt32 minSpanIndex, in SInt32 maxSpanIndex, io Float32 N<> )

EvaluateNurbsBasis_uniformKnots: optimizes EvaluateNurbsBasis for uniform knot cases, where knot span deltas are either 1 or 0 (at start/end). minSpanIndex and maxSpanIndex: in the range [0..degree*2-1], the indices from which the knot spans are 0 (min=0 and max=degree*2-1 if none) Timings showed that this version gives a 40% speed increase over EvaluateNurbsBasis in optimized KL


Color GetAttributeAtLocation ( in Ref<SpatialQueryable> geometry, in GeometryLocation location, in Ref<ColorAttribute> attribute )

GeometryLocation helper: evaluates a ColorAttribute a specific location. The location must be valid, and must have been created by the Geometry or one with the same structure, and no structure changes should have been made.


Integer GetAttributeAtLocation ( in Ref<SpatialQueryable> geometry, in GeometryLocation location, in Ref<IntegerAttribute> attribute )

GeometryLocation helper: evaluates a IntegerAttribute a specific location.


Mat33 GetAttributeAtLocation ( in Ref<SpatialQueryable> geometry, in GeometryLocation location, in Ref<Mat33Attribute> attribute )

GeometryLocation helper: evaluates a Mat33Attribute a specific location. The location must be valid, and must have been created by the Geometry or one with the same structure, and no structure changes should have been made.


Mat44 GetAttributeAtLocation ( in Ref<SpatialQueryable> geometry, in GeometryLocation location, in Ref<Mat44Attribute> attribute )

GeometryLocation helper: evaluates a Mat44Attribute a specific location. The location must be valid, and must have been created by the Geometry or one with the same structure, and no structure changes should have been made.


Quat GetAttributeAtLocation ( in Ref<SpatialQueryable> geometry, in GeometryLocation location, in Ref<QuatAttribute> attribute )

GeometryLocation helper: evaluates a QuatAttribute a specific location. The location must be valid, and must have been created by the Geometry or one with the same structure, and no structure changes should have been made.


RGBA GetAttributeAtLocation ( in Ref<SpatialQueryable> geometry, in GeometryLocation location, in Ref<RGBAAttribute> attribute )

GeometryLocation helper: evaluates a RGBAAttribute a specific location. The location must be valid, and must have been created by the Geometry or one with the same structure, and no structure changes should have been made.


RGB GetAttributeAtLocation ( in Ref<SpatialQueryable> geometry, in GeometryLocation location, in Ref<RGBAttribute> attribute )

GeometryLocation helper: evaluates a RGBAttribute a specific location. The location must be valid, and must have been created by the Geometry or one with the same structure, and no structure changes should have been made.


Scalar GetAttributeAtLocation ( in Ref<SpatialQueryable> geometry, in GeometryLocation location, in Ref<ScalarAttribute> attribute )

GeometryLocation helper: evaluates a ScalarAttribute a specific location.


LocalL16ScalarArray GetAttributeAtLocation ( in Ref<SpatialQueryable> geometry, in GeometryLocation location, in Ref<ScalarConstantArrayAttribute> attribute )

GeometryLocation helper: evaluates a ScalarConstantArrayAttribute a specific location. The location must be valid, and must have been created by the Geometry or one with the same structure, and no structure changes should have been made.


LocalL16UInt16Array GetAttributeAtLocation ( in Ref<SpatialQueryable> geometry, in GeometryLocation location, in Ref<UInt16ConstantArrayAttribute> attribute )

GeometryLocation helper: evaluates a UInt16ConstantArrayAttribute a specific location. The location must be valid, and must have been created by the Geometry or one with the same structure, and no structure changes should have been made.


UInt32 GetAttributeAtLocation ( in Ref<SpatialQueryable> geometry, in GeometryLocation location, in Ref<UInt32Attribute> attribute )

GeometryLocation helper: evaluates a UInt32Attribute a specific location. The location must be valid, and must have been created by the Geometry or one with the same structure, and no structure changes should have been made.


Vec2 GetAttributeAtLocation ( in Ref<SpatialQueryable> geometry, in GeometryLocation location, in Ref<Vec2Attribute> attribute )

GeometryLocation helper: evaluates a Vec2Attribute a specific location. The location must be valid, and must have been created by the Geometry or one with the same structure, and no structure changes should have been made.


Vec3 GetAttributeAtLocation ( in Ref<SpatialQueryable> geometry, in GeometryLocation location, in Ref<Vec3Attribute> attribute )

GeometryLocation helper: evaluates a Vec3Attribute a specific location. The location must be valid, and must have been created by the Geometry or one with the same structure, and no structure changes should have been made.


Vec3_d GetAttributeAtLocation ( in Ref<SpatialQueryable> geometry, in GeometryLocation location, in Ref<Vec3_dAttribute> attribute )

GeometryLocation helper: evaluates a Vec3_dAttribute a specific location. The location must be valid, and must have been created by the Geometry or one with the same structure, and no structure changes should have been made.


Vec4 GetAttributeAtLocation ( in Ref<SpatialQueryable> geometry, in GeometryLocation location, in Ref<Vec4Attribute> attribute )

GeometryLocation helper: evaluates a Vec4Attribute a specific location. The location must be valid, and must have been created by the Geometry or one with the same structure, and no structure changes should have been made.


Ref<PerCurveSamplingTable> GetPerCurveSamplingTable ( in UInt32 sampling )


Boolean IsEmptyCurvesSpanRange ( in Vec2 range )


UInt32 NextOff ( in UInt32 offset, in UInt32 count )

Returns the next offset (or index) within a circular array of size count. This is useful when accessing polygon’s next polygonPointIndex or point’s next pointNeighborIndex.


PrepareForSpatialQueries_setOctree ( io GenericValueContainer options )

Helper for initializing SpatialQueryable.prepareForSpatialQueries options: sets preferred acceleration method as Octree (which is the default).


PrepareForSpatialQueries_setOctreeMaxDepth ( io GenericValueContainer options, in UInt8 octreeMaxDepth )

Helper for initializing SpatialQueryable.prepareForSpatialQueries options: sets Octree ‘s maximum depth.


PrepareForSpatialQueries_setSparseGrid ( io GenericValueContainer options )

Helper for initializing SpatialQueryable.prepareForSpatialQueries options: sets preferred acceleration method as SparseGrid (default: Octree).


PrepareForSpatialQueries_setSparseGridAutoCellSizeMultiplier ( io GenericValueContainer options, in Scalar autoCellSizeMultiplier )

Helper for initializing SpatialQueryable.prepareForSpatialQueries options: sets SparseGrid ‘s auto cellSize factor (default: 1.0).


PrepareForSpatialQueries_setSparseGridCellSize ( io GenericValueContainer options, in Scalar cellSize )

Helper for initializing SpatialQueryable.prepareForSpatialQueries options: sets SparseGrid ‘s cellSize (default: auto cellSize).


UInt32 PrevOff ( in UInt32 offset, in UInt32 count )

Returns the previous offset (or index) within a circular array of size count. This is useful when accessing polygon’s previous polygonPointIndex or point’s previous pointNeighborIndex.


Mat44 asymmetricOrthographicFrustum ( in Scalar lx, in Scalar ly, in Scalar ux, in Scalar uy, in Scalar n, in Scalar f )

Builds an orthographic projection matrix, which transforms the box range [lx, ly, n] .. [ux,uy, f] into [-1, -1, -1] .. [1, 1, 1].

lx Lower x of the view
ly Lower y of the view
ux Upper x of the view
uy Upper y of the view
n Near plane distance
f Far plane distance


UInt8 bBoxGetBSphereIntersection ( in Vec2 min, in Vec2 max, in Vec2 sphereCenter, in Scalar sphereRadius )

Returns the intersection result of a 2D sphere with a 2D box. IntersectionOverlap is returned if the sphere is both outside and inside of the bounding box IntersectionIncludesOther is returned if the sphere is completely inside the bounding box IntersectionNone is returned if the sphere is completely outside of the bounding box


UInt8 bBoxGetBSphereIntersection ( in Vec3 min, in Vec3 max, in Vec3 sphereCenter, in Scalar sphereRadius )

Returns the intersection result of a sphere with a box. IntersectionOverlap is returned if the sphere is both outside and inside of the bounding box IntersectionIncludesOther is returned if the sphere is completely inside the bounding box IntersectionNone is returned if the sphere is completely outside of the bounding box


Vec3 bBoxGetClosestPoint ( in Vec3 bBoxMin, in Vec3 bBoxMax, in Vec3 position )

If the point is outside the bounding box, returns the closest point on the bounding box formed by bBoxMin and bBoxMax. Else, the point is returned.


Boolean bBoxIntersectsBBox ( in Vec3 min1, in Vec3 max1, in Vec3 min2, in Vec3 max2 )

Returns true if the bounding box formed by min1 and max1 intersects the one formed by min2 and max2


Boolean bBoxIntersectsBSphere ( in Vec3 bBoxMin, in Vec3 bBoxMax, in Vec3 bSphereCenter, in Scalar bSphereSquaredRadius )

Returns true if the bounding box formed by bBoxMin and bBoxMax intersects the sphere centered at bSphereCenter with a squared radius of bSphereSquaredRadius.


UInt8 bSphereGetBBoxIntersection ( in Vec3 sphereCenter, in Scalar sphereRadius, in Vec3 min, in Vec3 max )

Returns the intersection result of a box with a sphere. IntersectionOverlap is returned if the box is both outside and inside of the sphere IntersectionIncludesOther is returned if the box is completely inside the sphere IntersectionNone is returned if the box is completely outside of the sphere


getBBoxPoints ( in Vec3 min, in Vec3 max, out Vec3 pts[8] )

Returns the 8 corner positions of the bbox


Scalar getDistanceToBBox ( in Box3 bBox, in Vec3 position )

Returns the squared distance to the bbox


Scalar getSquaredDistanceToBBox ( in Box3 bBox, in Vec3 position )

Returns the squared distance to the bbox


Scalar getSquaredDistanceToTransformedBVol ( in LocalBoundingVolume localBVol, in Mat44 localBVolTransfo, in Vec3 globalPos )

Returns the distance from a point to a transformed LocalBoundingVolume


localBVolGetBBox ( in Mat44 transform, in LocalBoundingVolume localBVol, out Vec3 min, out Vec3 max )

Returns a bounding box englobing the transformed LocalBoundingVolume


localBVolGetBSphere ( in Mat44 transform, in LocalBoundingVolume localBVol, out Vec3 bSphereCenter, out Scalar bSphereSquaredRadius )

Returns a bounding sphere englobing the transformed LocalBoundingVolume


Mat44 symmetricOrthographicFrustum ( in Scalar w, in Scalar h, in Scalar n, in Scalar f )

Builds an orthographic projection matrix, which transforms the box range [-w/2, -h/2, n] .. [w/2, h/2, f] into [-1, -1, -1] .. [1, 1, 1].

w Width of the view (ranging from -w/2 to w/2)
h Height of the view (ranging from -h/2 to h/2)
n Near plane distance
f Far plane distance


Mat44 symmetricPerspectiveFrustum ( in Scalar nearWidth, in Scalar nearHeight, in Scalar near, in Scalar far, in Scalar centerX, in Scalar centerY )

Builds a symmetric perspective projection matrix

nearWidth Width at the near plane of the truncated pyramid
nearHeight Height at the near plane of the truncated pyramid
near Near plane distance
far Far plane distance
centerX Translation in X to be applied after the projection
centerY Translation in Y to be applied after the projection


transformedBBoxGetBBox ( in Mat44 transform, in LocalBoundingVolume localBVol, out Vec3 min, out Vec3 max )

Returns the global bounding box of a transformed bounding box (LocalBoundingVolume must be a box)


transformedBBoxGetBSphere ( in Mat44 transform, in Vec3 bBoxMin, in Vec3 bBoxMax, out Vec3 bSphereCenter, out Scalar bSphereSquaredRadius )

Returns an approximate bounding sphere for the bounding box formed by bBoxMin and bBoxMax, and transformed with transform.


transformedBBoxGetVectors ( in Mat44 transform, in LocalBoundingVolume localBVol, out Vec3 origin, out Vec3 dX, out Vec3 dY, out Vec3 dZ )

Transforms the bounding box and returns a transformed origin and axis (dX, dY, dZ) (LocalBoundingVolume must be a box)


transformedBSphereGetBBox ( in Mat44 transform, in LocalBoundingVolume localBVol, out Vec3 min, out Vec3 max )

Returns the bounding box of a transformed sphere (LocalBoundingVolume must be a sphere)


transformedBSphereGetBSphere ( in Mat44 transform, in Vec3 localCenter, in Scalar localRadius, out Vec3 bSphereCenter, out Scalar bSphereSquaredRadius )

Returns the bounding sphere, in global space, of a transformed bounding sphere