API / geotoolkit3d / util / Math3DUtil / Math3DUtil
util.Math3DUtil.Math3DUtil
This utility class provides functions to deal with common 3D related math problems.
Constructors
Methods
Methods
▸ Static angleToEuler(axis, angle, result?): Euler
Casts angles between two Vector3's to euler angles
See http://www.euclideanspace.com/maths/geometry/rotations/conversions/angleToEuler/index.htm
| Name | Type | Description |
|---|---|---|
axis | Vector3 | axis of rotation |
angle | number | angle of rotation |
Optional result | Euler | the euler angle that can be returned as a result. If left empty, a new one will be created, if passed as parameter, it will be updated with the result. |
Euler
result
▸ Static areVectorsAlmostEqual(a, b, epsilon): boolean
Return true if the given vectors are almost equals, relative to epsilon.
| Name | Type | Description |
|---|---|---|
a | Vector3 | the first vector |
b | Vector3 | the second vector |
epsilon | number | if the difference in coordinates is smaller than epsilon, they are considered equal. |
boolean
▸ Static computeCellVolume(c): number
Compute the volume of the cell formed by the given set of 8 corners. This is achieved by dividing the cell into 6 tetrahedrons and computing the volume of each of them separately. Note that the cell corners must be given in the right order, following this schema: 0 ------- 1 |\ |
| \ |
| 2 ------- 3 4 -|----- 5 | \ | \ | | | 6 ------- 7
| Name | Type | Description |
|---|---|---|
c | number[][] | array[8] containing in each position the array [x,y,z] values of each corner |
number
The volume of the tetrahedron
▸ Static computeHeronArea(p0, p1, p2): number
Computes area of a triangle using Heron's formula.
This function computes the area of the triangle made by the three given points.
To do so, it uses the Heron's stabilized formula:
Let a, b, c the length of each edge of the triangle with (a >= b >= c).
∆ := √((a+(b+c)) (c-(a-b)) (c+(a-b)) (a+(b-c)))
See
| Name | Type | Description |
|---|---|---|
p0 | Vector2 | The first point |
p1 | Vector2 | The second point |
p2 | Vector2 | The third point |
number
The area of the triangle
▸ Static computeTetrahedronVolume(p1, p2, p3, p4): number
Compute the volume of the tetrahedron formed by the given set of 4 points. The tetrahedron can be irregular and of any shape. Formula based on https://en.wikipedia.org/wiki/Tetrahedron#Volume
| Name | Type | Description |
|---|---|---|
p1 | number[] | x,y,z values of a point |
p2 | number[] | x,y,z values of a point |
p3 | number[] | x,y,z values of a point |
p4 | number[] | x,y,z values of a point |
number
The volume of the tetrahedron
▸ Static containsBox(box1, box2): boolean
Returns if box2 is contained inside box1
| Name | Type | Description |
|---|---|---|
box1 | Box2 | First box |
box2 | Box2 | Second box |
boolean
box contained
▸ Static createFitBox(box1, box2): Box2
Returns a THREE.Box2 of the space contained by both boxes
| Name | Type | Description |
|---|---|---|
box1 | Box2 | First box |
box2 | Box2 | Second box |
Box2
overlapping space
▸ Static crossProduct(a, b, result?): number[]
Compute cross product of two array-based points and return as a new array
| Name | Type | Description |
|---|---|---|
a | number[] | array-based point1 |
b | number[] | array-based point2 |
Optional result | number[] | array-based vector result to avoid array creation |
number[]
array-based vector cross product result
▸ Static degreeToRadians(angle): number
Convert an angle in degree to radians.
| Name | Type | Description |
|---|---|---|
angle | number | The angle value in degree |
number
The angle in radians
▸ Static directionToEuler(direction, up, result?): Euler
Casts euler angles from direction and up vectors
See https://stackoverflow.com/questions/21622956/how-to-convert-direction-vector-to-euler-angles
| Name | Type | Description |
|---|---|---|
direction | Vector3 | direction vector |
up | Vector3 | up vector |
Optional result | Euler | euler angles |
Euler
result
▸ Static dotProduct(a, b): number
Compute dot product of two array-based points
| Name | Type | Description |
|---|---|---|
a | number[] | array-based point1 |
b | number[] | array-based point2 |
number
dot product
▸ Static getBoxToBoxMatrix(src, dst): Matrix4
Creates a box to box transformation matrix
| Name | Type | Description |
|---|---|---|
src | Box3 | Source box |
dst | Box3 | Target box |
Matrix4
▸ Static intersect(segment0p0, segment0p1, segment1p0, segment1p1): Vector2
Finds intersection between the given segments if there is any, null otherwise.
| Name | Type | Description |
|---|---|---|
segment0p0 | Point | Vector2 | First segment first point |
segment0p1 | Point | Vector2 | First segment second point |
segment1p0 | Point | Vector2 | Second segment first point |
segment1p1 | Point | Vector2 | Second segment second point |
Vector2
The intersection point or null
▸ Static intersectBox(b1, b2): boolean
Returns if the two boxes intersect
| Name | Type | Description |
|---|---|---|
b1 | Box2 | First box |
b2 | Box2 | Second box |
boolean
box intersect
▸ Static maxVector3(v1, v2): Vector3
Returns the maximum values of both vectors as a new vector
| Name | Type | Description |
|---|---|---|
v1 | Vector3 | First vector |
v2 | Vector3 | Second vector |
Vector3
A new vector containing the maximum value for each component
▸ Static minVector3(v1, v2): Vector3
Returns the minimum values of both vectors as a new vector
| Name | Type | Description |
|---|---|---|
v1 | Vector3 | First vector |
v2 | Vector3 | Second vector |
Vector3
A new vector containing the minimum value for each component
▸ Static minimumCurvature(measuredDepth, inclination, azimuth, neg?): Object
This function turns measuredDepths inclinations and azimuth into XYZ deviation coordinates
| Name | Type | Description |
|---|---|---|
measuredDepth | number[] | measured depth array |
inclination | number[] | inclination array |
azimuth | number[] | azimuth array |
Optional neg | boolean | resulting depths should be negative |
Object
| Name | Type |
|---|---|
x | number[] |
y | number[] |
z | number[] |
▸ Static normal(vertices, index0, index1, index2, normal?, nullvalue?): number[]
Computes the 'surface normal' of three vertex in the given array (at the given indices).
This will compute the normal vector of the plane made by the given 3 vertex.
| Name | Type | Description |
|---|---|---|
vertices | number[] | The xyz values of the vertices |
index0 | number | The first vector index |
index1 | number | The second vector index |
index2 | number | The third vector index |
Optional normal | number[] | Optional target array |
Optional nullvalue | number | A nullvalue to ignore (cannot be NaN) |
number[]
The resulting normal as an array of 3 components [x,y,z]
▸ Static normalBufferAttribute(vertices, index0, index1, index2, normal?, nullvalue?): number[]
Computes the 'surface normal' of three vertex in the given array (at the given indices).
This will compute the normal vector of the plane made by the given 3 vertex.
| Name | Type | Description |
|---|---|---|
vertices | BufferAttribute | InterleavedBufferAttribute | The xyz values of the vertices |
index0 | number | The first vector index |
index1 | number | The second vector index |
index2 | number | The third vector index |
Optional normal | number[] | Optional target array |
Optional nullvalue | number | A nullvalue to ignore (cannot be NaN) |
number[]
The resulting normal as an array of 3 components [x,y,z]
▸ Static normalizeArray(values, dststart?, dstend?, srcstart?, srcend?, nullvalue?, normednullvalue?): number[]
Creates a normalized version of the given array.
If given array's min&max are identical then the returned normalized values will be 'start + (end - start) / 2'.
If given srcstart is NaN the actual minimum will be used instead.
If given srcend is NaN the actual maximum will be used instead.
| Name | Type | Description |
|---|---|---|
values | number[] | Values to normalize |
Optional dststart | number | Normalization min value (ie normalized minimum value) |
Optional dstend | number | Normalization max value (ie normalized maximum value) |
Optional srcstart | number | Origin min value, by default will be the array actual min |
Optional srcend | number | Origin max value, by default will be the array actual max |
Optional nullvalue | number | A nullvalue to normalize differently, note that null and NaN are considered as nullvalue by default |
Optional normednullvalue | number | The normalized value to use in place of the nullvalue in the returned array |
number[]
The normalized values
▸ Static radiansToDegree(angle): number
Convert an angle in radians to degree.
| Name | Type | Description |
|---|---|---|
angle | number | The angle value in radians |
number
The angle in degrees
▸ Static resolveTransformMatrix3(src, dest): Matrix3
Returns transform matrix from three Vector3 to three Vector3
| Name | Type | Description |
|---|---|---|
src | Vector3[] | three Vector3 |
dest | Vector3[] | three Vector3 |
Matrix3
this
▸ Static resolveTransformMatrix4(src, dest): Matrix4
Returns transform matrix from four Vector3 to four Vector3
| Name | Type | Description |
|---|---|---|
src | Vector3[] | four Vector3 |
dest | Vector3[] | four Vector3 |
Matrix4
this