AR Design
UBC EML collab with UBC SALA - visualizing IoT data in AR
HoloToolkit.Unity.MathUtils Class Reference

Math Utilities class. More...

Static Public Member Functions

static float GetHorizontalFieldOfViewRadians ()
 Get the horizontal FOV from the stereo camera More...
 
static bool IsInFOV (Vector3 position)
 Returns if a point will be rendered on the screen in either eye More...
 
static Vector3 TransformPointFromTo (Transform from, Transform to, Vector3 ptInFrom)
 Takes a point in the coordinate space specified by the "from" transform and transforms it to be the correct point in the coordinate space specified by the "to" transform applies rotation, scale and translation More...
 
static Vector3 TransformDirectionFromTo (Transform from, Transform to, Vector3 dirInFrom)
 Takes a direction in the coordinate space specified by the "from" transform and transforms it to be the correct direction in the coordinate space specified by the "to" transform applies rotation only, no translation or scale More...
 
static Vector3 TransformVectorFromTo (Transform from, Transform to, Vector3 vecInFrom)
 Takes a vectpr in the coordinate space specified by the "from" transform and transforms it to be the correct direction in the coordinate space specified by the "to" transform applies rotation and scale, no translation More...
 
static Ray TransformRayFromTo (Transform from, Transform to, Ray rayToConvert)
 Takes a ray in the coordinate space specified by the "from" transform and transforms it to be the correct ray in the coordinate space specified by the "to" transform More...
 
static Quaternion QuaternionFromMatrix (Matrix4x4 m)
 Creates a quaternion containing the rotation from the input matrix. More...
 
static void ToTranslationRotation (Matrix4x4 unityMtx, out Vector3 translation, out Quaternion rotation)
 Extract the translation and rotation components of a Unity matrix More...
 
static Vector3 XZProject (Vector3 v)
 Project vector onto XZ plane More...
 
static Vector3 YZProject (Vector3 v)
 Project vector onto YZ plane More...
 
static Vector3 XYProject (Vector3 v)
 Project vector onto XY plane More...
 
static float DistanceOfPointToLine (Vector3 point, Vector3 linePointA, Vector3 linePointB)
 Returns the distance between a point and an infinite line defined by two points; linePointA and linePointB More...
 
static Vector3 ClosestPointOnLineToPoint (Vector3 point, Vector3 linePointA, Vector3 linePointB)
 
static float DistanceOfPointToLineSegment (Vector3 point, Vector3 lineStart, Vector3 lineEnd)
 
static Vector3 ClosestPointOnLineSegmentToPoint (Vector3 point, Vector3 lineStart, Vector3 lineEnd)
 
static bool TestPlanesAABB (Plane[] planes, int planeMask, Bounds bounds, out bool entirelyInside)
 
static bool InRange (Vector2 vec, Vector2 lower, Vector2 upper)
 Tests component-wise if a Vector2 is in a given range More...
 
static bool InRange (Vector3 vec, Vector3 lower, Vector3 upper)
 Tests component-wise if a Vector3 is in a given range More...
 
static Matrix4x4 Add (Matrix4x4 a, Matrix4x4 b)
 Element-wise addition of two Matrix4x4s - extension method More...
 
static Matrix4x4 Subtract (Matrix4x4 a, Matrix4x4 b)
 Element-wise subtraction of two Matrix4x4s - extension method More...
 
static float DistanceOfPointToLine (Ray ray, Vector3 point)
 find unsigned distance of 3D point to an infinite line More...
 
static Vector3 NearestPointToLines (Ray p, Ray q)
 Find 3D point that minimizes distance to 2 lines, midpoint of the shortest perpendicular line segment between them More...
 
static Vector3 NearestPointToLinesRANSAC (List< Ray > rays, int ransac_iterations, float ransac_threshold, out int numActualInliers)
 Find 3D point that minimizes distance to a set of 2 or more lines, ignoring outliers More...
 
static Vector3 NearestPointToLinesLeastSquares (IEnumerable< Ray > rays)
 Find 3D point that minimizes distance to a set of 2 or more lines More...
 

Detailed Description

Math Utilities class.

Definition at line 13 of file MathUtils.cs.

Member Function Documentation

§ Add()

static Matrix4x4 HoloToolkit.Unity.MathUtils.Add ( Matrix4x4  a,
Matrix4x4  b 
)
static

Element-wise addition of two Matrix4x4s - extension method

Parameters
amatrix
bmatrix
Returns
element-wise (a+b)

Definition at line 289 of file MathUtils.cs.

§ ClosestPointOnLineSegmentToPoint()

static Vector3 HoloToolkit.Unity.MathUtils.ClosestPointOnLineSegmentToPoint ( Vector3  point,
Vector3  lineStart,
Vector3  lineEnd 
)
static

Definition at line 190 of file MathUtils.cs.

§ ClosestPointOnLineToPoint()

static Vector3 HoloToolkit.Unity.MathUtils.ClosestPointOnLineToPoint ( Vector3  point,
Vector3  linePointA,
Vector3  linePointB 
)
static

Definition at line 170 of file MathUtils.cs.

§ DistanceOfPointToLine() [1/2]

static float HoloToolkit.Unity.MathUtils.DistanceOfPointToLine ( Vector3  point,
Vector3  linePointA,
Vector3  linePointB 
)
static

Returns the distance between a point and an infinite line defined by two points; linePointA and linePointB

Parameters
point
linePointA
linePointB
Returns

Definition at line 164 of file MathUtils.cs.

§ DistanceOfPointToLine() [2/2]

static float HoloToolkit.Unity.MathUtils.DistanceOfPointToLine ( Ray  ray,
Vector3  point 
)
static

find unsigned distance of 3D point to an infinite line

Parameters
rayray that specifies an infinite line
point3D point
Returns
unsigned perpendicular distance from point to line

Definition at line 321 of file MathUtils.cs.

§ DistanceOfPointToLineSegment()

static float HoloToolkit.Unity.MathUtils.DistanceOfPointToLineSegment ( Vector3  point,
Vector3  lineStart,
Vector3  lineEnd 
)
static

Definition at line 184 of file MathUtils.cs.

§ GetHorizontalFieldOfViewRadians()

static float HoloToolkit.Unity.MathUtils.GetHorizontalFieldOfViewRadians ( )
static

Get the horizontal FOV from the stereo camera

Returns

Definition at line 20 of file MathUtils.cs.

§ InRange() [1/2]

static bool HoloToolkit.Unity.MathUtils.InRange ( Vector2  vec,
Vector2  lower,
Vector2  upper 
)
static

Tests component-wise if a Vector2 is in a given range

Parameters
vecThe vector to test
lowerThe lower bounds
upperThe upper bounds
Returns
true if in range, otherwise false

Definition at line 266 of file MathUtils.cs.

§ InRange() [2/2]

static bool HoloToolkit.Unity.MathUtils.InRange ( Vector3  vec,
Vector3  lower,
Vector3  upper 
)
static

Tests component-wise if a Vector3 is in a given range

Parameters
vecThe vector to test
lowerThe lower bounds
upperThe upper bounds
Returns
true if in range, otherwise false

Definition at line 278 of file MathUtils.cs.

§ IsInFOV()

static bool HoloToolkit.Unity.MathUtils.IsInFOV ( Vector3  position)
static

Returns if a point will be rendered on the screen in either eye

Parameters
position
Returns

Definition at line 31 of file MathUtils.cs.

§ NearestPointToLines()

static Vector3 HoloToolkit.Unity.MathUtils.NearestPointToLines ( Ray  p,
Ray  q 
)
static

Find 3D point that minimizes distance to 2 lines, midpoint of the shortest perpendicular line segment between them

Parameters
pray that specifies a line
qray that specifies a line
Returns
point nearest to the lines

Definition at line 332 of file MathUtils.cs.

§ NearestPointToLinesLeastSquares()

static Vector3 HoloToolkit.Unity.MathUtils.NearestPointToLinesLeastSquares ( IEnumerable< Ray >  rays)
static

Find 3D point that minimizes distance to a set of 2 or more lines

Parameters
rayseach ray specifies an infinite line
Returns
point nearest to the set of lines

Definition at line 408 of file MathUtils.cs.

§ NearestPointToLinesRANSAC()

static Vector3 HoloToolkit.Unity.MathUtils.NearestPointToLinesRANSAC ( List< Ray >  rays,
int  ransac_iterations,
float  ransac_threshold,
out int  numActualInliers 
)
static

Find 3D point that minimizes distance to a set of 2 or more lines, ignoring outliers

Parameters
rayslist of rays, each specifying a line, must have at least 1
ransac_iterationsnumber of iterations: log(1-p)/log(1-(1-E)^s) where p is probability of at least one sample containing s points is all inliers E is proportion of outliers (1-ransac_ratio) e.g. p=0.999, ransac_ratio=0.54, s=2 ==> log(0.001)/(log(1-0.54^2) = 20
ransac_thresholdminimum distance from point to line for a line to be considered an inlier
numActualInliersreturn number of inliers: lines that are within ransac_threshold of nearest point
Returns
point nearest to the set of lines, ignoring outliers

Definition at line 365 of file MathUtils.cs.

§ QuaternionFromMatrix()

static Quaternion HoloToolkit.Unity.MathUtils.QuaternionFromMatrix ( Matrix4x4  m)
static

Creates a quaternion containing the rotation from the input matrix.

Parameters
mInput matrix to convert to quaternion
Returns

Definition at line 100 of file MathUtils.cs.

§ Subtract()

static Matrix4x4 HoloToolkit.Unity.MathUtils.Subtract ( Matrix4x4  a,
Matrix4x4  b 
)
static

Element-wise subtraction of two Matrix4x4s - extension method

Parameters
amatrix
bmatrix
Returns
element-wise (a-b)

Definition at line 305 of file MathUtils.cs.

§ TestPlanesAABB()

static bool HoloToolkit.Unity.MathUtils.TestPlanesAABB ( Plane []  planes,
int  planeMask,
Bounds  bounds,
out bool  entirelyInside 
)
static

Definition at line 214 of file MathUtils.cs.

§ ToTranslationRotation()

static void HoloToolkit.Unity.MathUtils.ToTranslationRotation ( Matrix4x4  unityMtx,
out Vector3  translation,
out Quaternion  rotation 
)
static

Extract the translation and rotation components of a Unity matrix

Definition at line 119 of file MathUtils.cs.

§ TransformDirectionFromTo()

static Vector3 HoloToolkit.Unity.MathUtils.TransformDirectionFromTo ( Transform  from,
Transform  to,
Vector3  dirInFrom 
)
static

Takes a direction in the coordinate space specified by the "from" transform and transforms it to be the correct direction in the coordinate space specified by the "to" transform applies rotation only, no translation or scale

Parameters
from
to
dirInFrom
Returns

Definition at line 59 of file MathUtils.cs.

§ TransformPointFromTo()

static Vector3 HoloToolkit.Unity.MathUtils.TransformPointFromTo ( Transform  from,
Transform  to,
Vector3  ptInFrom 
)
static

Takes a point in the coordinate space specified by the "from" transform and transforms it to be the correct point in the coordinate space specified by the "to" transform applies rotation, scale and translation

Parameters
from
to
ptInFrom
Returns

Definition at line 44 of file MathUtils.cs.

§ TransformRayFromTo()

static Ray HoloToolkit.Unity.MathUtils.TransformRayFromTo ( Transform  from,
Transform  to,
Ray  rayToConvert 
)
static

Takes a ray in the coordinate space specified by the "from" transform and transforms it to be the correct ray in the coordinate space specified by the "to" transform

Definition at line 84 of file MathUtils.cs.

§ TransformVectorFromTo()

static Vector3 HoloToolkit.Unity.MathUtils.TransformVectorFromTo ( Transform  from,
Transform  to,
Vector3  vecInFrom 
)
static

Takes a vectpr in the coordinate space specified by the "from" transform and transforms it to be the correct direction in the coordinate space specified by the "to" transform applies rotation and scale, no translation

Parameters
from
to
vecInFrom
Returns

Definition at line 74 of file MathUtils.cs.

§ XYProject()

static Vector3 HoloToolkit.Unity.MathUtils.XYProject ( Vector3  v)
static

Project vector onto XY plane

Parameters
v
Returns
result of projecting v onto XY plane

Definition at line 152 of file MathUtils.cs.

§ XZProject()

static Vector3 HoloToolkit.Unity.MathUtils.XZProject ( Vector3  v)
static

Project vector onto XZ plane

Parameters
v
Returns
result of projecting v onto XZ plane

Definition at line 132 of file MathUtils.cs.

§ YZProject()

static Vector3 HoloToolkit.Unity.MathUtils.YZProject ( Vector3  v)
static

Project vector onto YZ plane

Parameters
v
Returns
result of projecting v onto YZ plane

Definition at line 142 of file MathUtils.cs.


The documentation for this class was generated from the following file: