struct Vector3
in global
A point in 3D space.
public float x { get; set; }
The X component of this Vector.
public float y { get; set; }
The Y component of this Vector.
public float z { get; set; }
The Z component of this Vector.
public Vector3( float x, float y, float z )
Initializes a vector with given components.
xThe X component.yThe Y component.zThe Z component.
public Vector3( float x, float y )
Initializes a vector with given components and Z set to 0.
xThe X component.yThe Y component.
public Vector3( ref Vector3 other )
Initializes a vector3 from a given vector3, i.e. a copy.
public Vector3( ref Vector2 other, float z )
Initializes a vector3 from given vector2 and the given Z component.
public Vector3( float all = 0 )
Initializes the vector with all components set to given value.
public static Vector3 One
A vector with all components set to 1.
public static Vector3 Zero
A vector with all components set to 0.
public static Vector3 Forward
A vector with X set to 1. This represents the forwards direction.
public static Vector3 Backward
A vector with X set to -1. This represents the backwards direction.
public static Vector3 Up
A vector with Z set to 1. This represents the upwards direction.
public static Vector3 Down
A vector with Z set to -1. This represents the downwards direction.
public static Vector3 Right
A vector with Y set to -1. This represents the right hand direction.
public static Vector3 Left
A vector with Y set to 1. This represents the left hand direction.
public Vector3 Normal { get; }
Returns a unit version of this vector. A unit vector has length of 1.
public static Vector3 Random { get; }
Uniformly samples a 3D position from all points with distance at most 1 from the origin.
public bool IsNaN { get; }
Returns true if x, y or z are NaN
public bool IsInfinity { get; }
Returns true if x, y or z are infinity
public Vector3 WithX( float x )
Returns this vector with given X component.
xThe override for X component.- Returns The new vector.
public Vector3 WithY( float y )
Returns this vector with given Y component.
yThe override for Y component.- Returns The new vector.
public Vector3 WithZ( float z )
Returns this vector with given Z component.
zThe override for Z component.- Returns The new vector.
public float Length { get; }
Length (or magnitude) of the vector (Distance from 0,0,0).
public float LengthSquared { get; }
Squared length of the vector. This is faster than Length, and can be used for things like comparing distances, as long as only squared values are used.
public bool IsNearZeroLength { get; }
Whether length of this vector is nearly zero.
public bool IsNearlyZero( float tolerance = 0.0001 )
Returns true if value on every axis is less than tolerance away from zero
public Vector3 ClampLength( float maxLength )
Returns a vector whose length is limited to given maximum.
public Vector3 ClampLength( float minLength, float maxLength )
Returns a vector whose length is limited between given minimum and maximum.
public Vector3 Clamp( Vector3 otherMin, Vector3 otherMax )
Returns a vector each axis of which is clamped to between the 2 given vectors. Basically clamps a point to an Axis Aligned Bounding Box (AABB).
otherMinThe mins vector. Values on each axis should be smaller than those of the maxs vector. See Vector3.Sort.otherMaxThe maxs vector. Values on each axis should be bigger than those of the mins vector. See Vector3.Sort.
public Vector3 Clamp( float min, float max )
Returns a vector each axis of which is clamped to given min and max values.
minMinimum value for each axis.maxMaximum value for each axis.
public static Vector3 Clamp( ref Vector3 value, ref Vector3 min, ref Vector3 max )
Restricts a vector between a minimum and a maximum value.
valueThe vector to restrict.minThe mins vector. Values on each axis should be smaller than those of the maxs vector. See Vector3.Sort.maxThe maxs vector. Values on each axis should be bigger than those of the mins vector. See Vector3.Sort.
public Vector3 ComponentMin( ref Vector3 other )
Returns a vector that has the minimum values on each axis between this vector and given vector.
public static Vector3 Min( ref Vector3 a, ref Vector3 b )
Returns a vector that has the minimum values on each axis between the 2 given vectors.
public Vector3 ComponentMax( ref Vector3 other )
Returns a vector that has the maximum values on each axis between this vector and given vector.
public static Vector3 Max( ref Vector3 a, ref Vector3 b )
Returns a vector that has the maximum values on each axis between the 2 given vectors.
public static Vector3 Lerp( Vector3 a, Vector3 b, float frac, bool clamp = True )
Performs linear interpolation between 2 given vectors.
aVector AbVector BfracFraction, where 0 would return Vector A, 0.5 would return a point between the 2 vectors, and 1 would return Vector B.clampWhether to clamp the fraction argument between [0,1]
public Vector3 LerpTo( ref Vector3 target, float frac, bool clamp = True )
Performs linear interpolation between this and given vectors.
targetVector BfracFraction, where 0 would return this, 0.5 would return a point between this and given vectors, and 1 would return the given vector.clampWhether to clamp the fraction argument between [0,1]
public static Vector3 Lerp( ref Vector3 a, ref Vector3 b, Vector3 frac, bool clamp = True )
Performs linear interpolation between 2 given vectors, with separate fraction for each vector component.
aVector AbVector BfracFraction for each axis, where 0 would return Vector A, 0.5 would return a point between the 2 vectors, and 1 would return Vector B.clampWhether to clamp the fraction argument between [0,1] on each axis
public Vector3 LerpTo( ref Vector3 target, ref Vector3 frac, bool clamp = True )
Performs linear interpolation between this and given vectors, with separate fraction for each vector component.
targetVector BfracFraction for each axis, where 0 would return this, 0.5 would return a point between this and given vectors, and 1 would return the given vector.clampWhether to clamp the fraction argument between [0,1] on each axis
public static Vector3 Slerp( Vector3 a, Vector3 b, float frac, bool clamp = True )
Performs spherical linear interpolation (Slerp) between two vectors.
aStarting vector (A).bTarget vector (B).fracInterpolation fraction: 0 returns A, 1 returns B, and values in between provide intermediate results along the spherical path.clampIf true, clamps the fraction between 0 and 1.- Returns Interpolated vector along the spherical path.
public Vector3 SlerpTo( ref Vector3 target, float frac, bool clamp = True )
Performs spherical linear interpolation (Slerp) between this vector and a target vector.
targetThe target vector to interpolate towards.fracInterpolation fraction: 0 returns this vector, 1 returns the target vector, and values in between provide intermediate results along the spherical path.clampIf true, clamps the fraction between 0 and 1.- Returns Interpolated vector along the spherical path.
public static float InverseLerp( Vector3 pos, Vector3 a, Vector3 b, bool clamp = True )
Given a position, and two other positions, calculate the inverse lerp position between those
public static Vector3 Cross( ref Vector3 a, ref Vector3 b )
Returns the cross product of the 2 given vectors. If the given vectors are linearly independent, the resulting vector is perpendicular to them both, also known as a normal of a plane.
public Vector3 Cross( ref Vector3 b )
Returns the cross product of this and the given vector. If this and the given vectors are linearly independent, the resulting vector is perpendicular to them both, also known as a normal of a plane.
public static float Dot( ref Vector3 a, ref Vector3 b )
Returns the scalar/dot product of the 2 given vectors.
public float Dot( ref Vector3 b )
Returns the scalar/dot product of this and the given vectors.
public static float DistanceBetween( ref Vector3 a, ref Vector3 b )
Returns distance between the 2 given vectors.
public float Distance( ref Vector3 target )
Returns distance between this vector to given vector.
public static float DistanceBetweenSquared( ref Vector3 a, ref Vector3 b )
Returns squared distance between the 2 given vectors. This is faster than DistanceBetween, and can be used for things like comparing distances, as long as only squared values are used.
public float DistanceSquared( ref Vector3 target )
Returns squared distance between this vector to given vector. This is faster than Distance, and can be used for things like comparing distances, as long as only squared values are used.
public Vector3 Approach( float length, float amount )
Returns a new vector whose length is closer to given target length by given amount.
lengthTarget length.amountHow much to subtract or add.
public static Vector3 Abs( ref Vector3 value )
Returns a new vector with all values positive. -5 becomes 5, etc.
public static Vector3 Reflect( ref Vector3 direction, ref Vector3 normal )
Returns a reflected vector based on incoming direction and plane normal. Like a ray reflecting off of a mirror.
public static Vector3 VectorPlaneProject( ref Vector3 v, ref Vector3 planeNormal )
Projects given vector on a plane defined by .
vThe vector to project.planeNormalNormal of a plane to project onto.- Returns The projected vector.
public Vector3 ProjectOnNormal( ref Vector3 normal )
Projects this vector onto another vector. Basically extends the given normal/unit vector to be as long as necessary to make a right triangle (a triangle which has a 90 degree corner) between (0,0,0), this vector and the projected vector.
- Returns The projected vector.
public static void Sort( ref Vector3 min, ref Vector3 max )
Sort these two vectors into min and max. This doesn't just swap the vectors, it sorts each component. So that min will come out containing the minimum x, y and z values.
public bool AlmostEqual( ref Vector3 v, float delta = 0.0001 )
Returns true if we're nearly equal to the passed vector.
vThe value to compare withdeltaThe max difference between component values- Returns True if nearly equal
public static Vector3 CubicBezier( ref Vector3 source, ref Vector3 target, ref Vector3 sourceTangent, ref Vector3 targetTangent, float t )
Calculates position of a point on a cubic beizer curve at given fraction.
sourcePoint A of the curve in world space.targetPoint B of the curve in world space.sourceTangentTangent for the Point A in world space.targetTangentTangent for the Point B in world space.tHow far along the path to get a point on. Range is 0 to 1, inclusive.- Returns The point on the curve
public static Vector3 Direction( ref Vector3 from, ref Vector3 to )
Calculates the normalized direction vector from one point to another in 3D space.
public Vector3 SubtractDirection( ref Vector3 direction, float strength = 1 )
Given a vector like 1,1,1 and direction 1,0,0, will return 0,1,1. This is useful for velocity collision type events, where you want to cancel out velocity based on a normal. For this to work properly, direction should be a normal, but you can scale how much you want to subtract by scaling the direction. Ie, passing in a direction with a length of 0.5 will remove half the direction.
public Vector3 SnapToGrid( float gridSize, bool sx = True, bool sy = True, bool sz = True )
Snap to grid along any of the 3 axes.
public static float GetAngle( ref Vector3 v1, ref Vector3 v2 )
Return the distance between the two direction vectors in degrees.
public float Angle( ref Vector3 v2 )
Return the distance between the two direction vectors in degrees.
public static Angles VectorAngle( ref Vector3 vec )
Converts a direction vector to an angle.
public Angles EulerAngles { get; set; }
The Euler angles of this direction vector.
public Vector3 Inverse { get; }
Returns the inverse of this vector, which us useful for scaling vectors.
public Vector3 AddClamped( ref Vector3 toAdd, float maxLength )
Try to add to this vector. If we're already over max then don't add. If we're over max when we add, clamp in that direction so we're not.
public Vector3 RotateAround( ref Vector3 center, ref Rotation rot )
Rotate this vector around given point by given rotation and return the result as a new vector. See for similar method that also transforms rotation.
centerPoint to rotate around.rotHow much to rotate by. can be useful.- Returns The rotated vector.
public static Vector3 Parse( string str, IFormatProvider provider )
🤡 Doc inheritance is not yet supported.
No summary.
public static Vector3 Parse( string str )
🤡 Doc inheritance is not yet supported.
No summary.
public static bool TryParse( string str, ref Vector3 result )
🤡 Doc inheritance is not yet supported.
No summary.
public static bool TryParse( string str, IFormatProvider provider, ref Vector3 result )
Given a string, try to convert this into a vector. Example input formats that work would be "1,1,1", "1;1;1", "[1 1 1]". This handles a bunch of different separators ( ' ', ',', ';', '\n', '\r' ). It also trims surrounding characters ('[', ']', ' ', '\n', '\r', '\t', '"').
public Vector3 WithAcceleration( Vector3 target, float acceleration )
Move to the target vector, by amount acceleration
public Vector3 WithFriction( float frictionAmount, float stopSpeed = 140 )
Apply an amount of friction to the current velocity.
public static Vector3 CatmullRomSpline( ref Vector3 p0, ref Vector3 p1, ref Vector3 p2, ref Vector3 p3, float t )
Calculates a point on a Catmull-Rom spline given four control points and a parameter t.
public static Vector3 TcbSpline( ref Vector3 p0, ref Vector3 p1, ref Vector3 p2, ref Vector3 p3, float tension, float continuity, float bias, float u )
Calculates an interpolated point using the Kochanek-Bartels spline (TCB spline).
tensionTension parameter which affects the sharpness at the control point. Positive values make the curve tighter, negative values make it rounder.continuityContinuity parameter which affects the continuity between segments. Positive values create smoother transitions, negative values can create corners.biasBias parameter which affects the direction of the curve as it passes through the control point. Positive values bias the curve towards the next point, negative values towards the previous.uThe interpolation parameter between 0 and 1, where 0 is the start of the segment and 1 is the end.- Returns The interpolated point on the curve.
public static Vector3 SmoothDamp( ref Vector3 current, ref Vector3 target, ref Vector3 velocity, float smoothTime, float deltaTime )
Smoothly move towards the target vector
public static Vector3 SpringDamp( ref Vector3 current, ref Vector3 target, ref Vector3 velocity, float smoothTime, float deltaTime, float frequency = 2, float damping = 0.5 )
Springly move towards the target vector
public Type GetType( )
😔 No documentation found.
public float Item { get; set; }
😔 No documentation found.
public Vector3 Abs( )
😔 No documentation found.
public string ToString( )
😔 No documentation found.
public static Vector3 op_Multiply( Vector3 c1, float f )
😔 No documentation found.
public static Vector3 op_Subtraction( Vector3 c1, Vector3 c2 )
😔 No documentation found.
public static Vector3 op_Addition( Vector3 c1, Vector3 c2 )
😔 No documentation found.
public static Vector3 op_Multiply( Vector3 c1, Vector3 c2 )
😔 No documentation found.
public static Vector3 op_Multiply( float f, Vector3 c1 )
😔 No documentation found.
public static Vector3 op_Division( Vector3 c1, float f )
😔 No documentation found.
public static Vector3 op_Division( Vector3 c1, ref Vector3 c2 )
😔 No documentation found.
public static Vector3 op_UnaryNegation( Vector3 value )
😔 No documentation found.
public static Vector3 op_Implicit( Color value )
😔 No documentation found.
public static Vector3 op_Implicit( float value )
😔 No documentation found.
public static Vector3 op_Multiply( Vector3 c1, Rotation f )
😔 No documentation found.
public static Vector3 op_Implicit( Vector2 value )
😔 No documentation found.
public static Vector3 op_Implicit( Vector3 value )
😔 No documentation found.
public static Vector3 op_Implicit( Vector3 value )
😔 No documentation found.
public static bool op_Equality( Vector3 left, Vector3 right )
😔 No documentation found.
public static bool op_Inequality( Vector3 left, Vector3 right )
😔 No documentation found.
public bool Equals( object obj )
😔 No documentation found.
public bool Equals( Vector3 o )
😔 No documentation found.
public static Vector3 op_Implicit( Vector4 vec )
😔 No documentation found.
public int GetHashCode( )
😔 No documentation found.