C# Class UEx.Vector3X

Vector3 extensions and helper functions
显示文件 Open project: jbruening/unity3d-extensions

Public Methods

Method Description
Abs ( this v ) : Vector3

Absolute value of components

AngleAroundAxis ( Vector3 dir1, Vector3 dir2, Vector3 axis ) : float

Approx ( Vector3 val, Vector3 about, float range ) : bool

test if a Vector3 is close to another Vector3 (due to floating point inprecision) compares the square of the distance to the square of the range as this avoids calculating a square root which is much slower than squaring the range

CalculateLineLineIntersection ( Vector3 line1Point1, Vector3 line1Point2, Vector3 line2Point1, Vector3 line2Point2, Vector3 &resultSegmentPoint1, Vector3 &resultSegmentPoint2 ) : bool

Calculates the intersection line segment between 2 lines (not segments). Returns false if no solution can be found.

Center ( Vector3 vec1, Vector3 vec2 ) : Vector3

Gets the center of two points

Center ( this points ) : Vector3

FastNormalized ( this vec1 ) : Vector3

Using the magic of 0x5f3759df

IsNaN ( this vec ) : bool

Lerp ( Vector3 v1, Vector3 v2, float value ) : Vector3

Direct speedup of Vector3.Lerp

MidPoint ( this first, Vector3 second ) : Vector3

NearestPoint ( Vector3 lineStart, Vector3 lineEnd, Vector3 point ) : Vector3

Find a point on the infinite line nearest to point

NearestPointStrict ( Vector3 lineStart, Vector3 lineEnd, Vector3 point ) : Vector3

find a point on the line segment nearest to point

ProjectOntoPlane ( this v, Vector3 planeNormal ) : Vector3

Vector3.Project, onto a plane

RandomDirection ( float spread, Vector3 forward ) : Vector3

Returns a random direction in a cone. a spread of 0 is straight, 0.5 is 180*

Sinerp ( Vector3 from, Vector3 to, float value ) : Vector3
SqrDistance ( this first, Vector3 second ) : float

gets the square distance between two vector3 positions. this is much faster that Vector3.distance.

SqrLineDistance ( this point, Vector3 lineP1, Vector3 lineP2, int &closestPoint ) : float

get the square distance from a point to a line segment.

Vector3Normal ( Vector3 vec1, Vector3 vec2, Vector3 vec3 ) : Vector3

Gets the normal of the triangle formed by the 3 vectors

Method Details

Abs() public static method

Absolute value of components
public static Abs ( this v ) : Vector3
v this
return UnityEngine.Vector3

AngleAroundAxis() public static method

public static AngleAroundAxis ( Vector3 dir1, Vector3 dir2, Vector3 axis ) : float
dir1 UnityEngine.Vector3
dir2 UnityEngine.Vector3
axis UnityEngine.Vector3
return float

Approx() public static method

test if a Vector3 is close to another Vector3 (due to floating point inprecision) compares the square of the distance to the square of the range as this avoids calculating a square root which is much slower than squaring the range
public static Approx ( Vector3 val, Vector3 about, float range ) : bool
val UnityEngine.Vector3
about UnityEngine.Vector3
range float
return bool

CalculateLineLineIntersection() public static method

Calculates the intersection line segment between 2 lines (not segments). Returns false if no solution can be found.
public static CalculateLineLineIntersection ( Vector3 line1Point1, Vector3 line1Point2, Vector3 line2Point1, Vector3 line2Point2, Vector3 &resultSegmentPoint1, Vector3 &resultSegmentPoint2 ) : bool
line1Point1 UnityEngine.Vector3
line1Point2 UnityEngine.Vector3
line2Point1 UnityEngine.Vector3
line2Point2 UnityEngine.Vector3
resultSegmentPoint1 UnityEngine.Vector3
resultSegmentPoint2 UnityEngine.Vector3
return bool

Center() public static method

Gets the center of two points
public static Center ( Vector3 vec1, Vector3 vec2 ) : Vector3
vec1 UnityEngine.Vector3
vec2 UnityEngine.Vector3
return UnityEngine.Vector3

Center() public static method

public static Center ( this points ) : Vector3
points this
return UnityEngine.Vector3

FastNormalized() public static method

Using the magic of 0x5f3759df
public static FastNormalized ( this vec1 ) : Vector3
vec1 this
return UnityEngine.Vector3

IsNaN() public static method

public static IsNaN ( this vec ) : bool
vec this
return bool

Lerp() public static method

Direct speedup of Vector3.Lerp
public static Lerp ( Vector3 v1, Vector3 v2, float value ) : Vector3
v1 UnityEngine.Vector3
v2 UnityEngine.Vector3
value float
return UnityEngine.Vector3

MidPoint() public static method

public static MidPoint ( this first, Vector3 second ) : Vector3
first this
second UnityEngine.Vector3
return UnityEngine.Vector3

NearestPoint() public static method

Find a point on the infinite line nearest to point
public static NearestPoint ( Vector3 lineStart, Vector3 lineEnd, Vector3 point ) : Vector3
lineStart UnityEngine.Vector3
lineEnd UnityEngine.Vector3
point UnityEngine.Vector3
return UnityEngine.Vector3

NearestPointStrict() public static method

find a point on the line segment nearest to point
public static NearestPointStrict ( Vector3 lineStart, Vector3 lineEnd, Vector3 point ) : Vector3
lineStart UnityEngine.Vector3
lineEnd UnityEngine.Vector3
point UnityEngine.Vector3
return UnityEngine.Vector3

ProjectOntoPlane() public static method

Vector3.Project, onto a plane
public static ProjectOntoPlane ( this v, Vector3 planeNormal ) : Vector3
v this
planeNormal UnityEngine.Vector3
return UnityEngine.Vector3

RandomDirection() public static method

Returns a random direction in a cone. a spread of 0 is straight, 0.5 is 180*
public static RandomDirection ( float spread, Vector3 forward ) : Vector3
spread float
forward UnityEngine.Vector3 must be unit
return UnityEngine.Vector3

Sinerp() public static method

public static Sinerp ( Vector3 from, Vector3 to, float value ) : Vector3
from UnityEngine.Vector3
to UnityEngine.Vector3
value float
return UnityEngine.Vector3

SqrDistance() public static method

gets the square distance between two vector3 positions. this is much faster that Vector3.distance.
public static SqrDistance ( this first, Vector3 second ) : float
first this first point
second UnityEngine.Vector3 second point
return float

SqrLineDistance() public static method

get the square distance from a point to a line segment.
public static SqrLineDistance ( this point, Vector3 lineP1, Vector3 lineP2, int &closestPoint ) : float
point this point to get distance to
lineP1 UnityEngine.Vector3 line segment start point
lineP2 UnityEngine.Vector3 line segment end point
closestPoint int set to either 1, 2, or 4, determining which end the point is closest to (p1, p2, or the middle)
return float

Vector3Normal() public static method

Gets the normal of the triangle formed by the 3 vectors
public static Vector3Normal ( Vector3 vec1, Vector3 vec2, Vector3 vec3 ) : Vector3
vec1 UnityEngine.Vector3
vec2 UnityEngine.Vector3
vec3 UnityEngine.Vector3
return UnityEngine.Vector3