-
Notifications
You must be signed in to change notification settings - Fork 0
Vector3 Extension
Deconstructs a Vector3 instance into its individual components.
Vector3 vector = // initialize your Vector3
float x, y, z;
vector.Deconstruct(out x, out y, out z);Parameters:
-
vector: The Vector3 instance.
Outputs:
-
x: The x component of the Vector3. -
y: The y component of the Vector3. -
z: The z component of the Vector3.
Creates a new Vector3 instance with the specified components, or the original components if not specified.
Vector3 originalVector = // initialize your Vector3
float? x = // optional
float? y = // optional
float? z = // optional
Vector3 newVector = originalVector.With(x, y, z);Parameters:
-
originalVector: The original Vector3 instance. -
x: The x component of the new Vector3. If null, the x component of the original Vector3 is used. -
y: The y component of the new Vector3. If null, the y component of the original Vector3 is used. -
z: The z component of the new Vector3. If null, the z component of the original Vector3 is used.
Returns:
-
newVector: A new Vector3 instance with the specified components.
Calculates the distance from a Vector3 to a point.
Vector3 vector = // initialize your Vector3
Vector3 point = // initialize the point
float distance = vector.Distance2Point(point);Parameters:
-
vector: The Vector3 instance. -
point: The point to calculate the distance to.
Returns:
-
distance: The distance from the Vector3 to the point.
Calculates the shortest distance from a Vector3 to a line segment.
Vector3 vector = // initialize your Vector3
Vector2 linePoint1 = // initialize the first point of the line segment
Vector2 linePoint2 = // initialize the second point of the line segment
float distance = vector.Distance2Line(linePoint1, linePoint2);Parameters:
-
vector: The Vector3 instance. -
linePoint1: The first point of the line segment. -
linePoint2: The second point of the line segment.
Returns:
-
distance: The shortest distance from the Vector3 to the line segment.
Clamps the components of a Vector3 between 0 and 1.
Vector3 vector = // initialize your Vector3
Vector3 clampedVector = vector.Clamp01();Parameters:
-
vector: The Vector3 instance.
Returns:
-
clampedVector: The clamped Vector3.
Clamps the components of a Vector3 between specified minimum and maximum values.
Vector3 vector = // initialize your Vector3
float min = // initialize the minimum value
float max = // initialize the maximum value
Vector3 clampedVector = vector.Clamp(min, max);Parameters:
-
vector: The Vector3 instance. -
min: The minimum value to clamp the components to. -
max: The maximum value to clamp the components to.
Returns:
-
clampedVector: The clamped Vector3.
Vector3 vector = // initialize your Vector3
Vector3 min = // initialize the minimum vector
Vector3 max = // initialize the maximum vector
Vector3 clampedVector = vector.Clamp(min, max);Parameters:
-
vector: The Vector3 instance. -
min: The minimum vector to clamp the components to. -
max: The maximum vector to clamp the components to.
Returns:
-
clampedVector: The clamped Vector3.
Flips a Vector3 in all directions.
Vector3 vector = // initialize your Vector3
Vector3 flippedVector = vector.Flip();Parameters:
-
vector: The Vector3 instance.
Returns:
-
flippedVector: The flipped Vector3.
Flips a Vector3 in the x direction.
Vector3 vector = // initialize your Vector3
Vector3 flippedVector = vector.FlipX();Parameters:
-
vector: The Vector3 instance.
Returns:
-
flippedVector: The flipped Vector3.
Flips a Vector3 in the y direction.
Vector3 vector = // initialize your Vector3
Vector3 flippedVector = vector.FlipY();Parameters:
-
vector: The Vector3 instance.
Returns:
-
flippedVector: The flipped Vector3.
`
Flips a Vector3 in the z direction.
Vector3 vector = // initialize your Vector3
Vector3 flippedVector = vector.FlipZ();Parameters:
-
vector: The Vector3 instance.
Returns:
-
flippedVector: The flipped Vector3.
Returns a Vector2 with the x and y components of a Vector3.
Vector3 vector = // initialize your Vector3
Vector2 xyVector = vector.GetXy();Parameters:
-
vector: The Vector3 instance.
Returns:
-
xyVector: A Vector2 with the x and y components of the Vector3.
Returns a Vector2 with the y and z components of a Vector3.
Vector3 vector = // initialize your Vector3
Vector2 yzVector = vector.GetYz();Parameters:
-
vector: The Vector3 instance.
Returns:
-
yzVector: A Vector2 with the y and z components of the Vector3.
Returns a Vector2 with the x and z components of a Vector3.
Vector3 vector = // initialize your Vector3
Vector2 xzVector = vector.GetXz();Parameters:
-
vector: The Vector3 instance.
Returns:
-
xzVector: A Vector2 with the x and z components of the Vector3.
Rotates a point around a pivot by specified Euler angles.
Vector3 point = // initialize the point to rotate
Vector3 pivot = // initialize the pivot point for the rotation
Vector3 eulerAngles = // initialize the Euler angles
Vector3 rotatedPoint = point.RotateAroundPivot(pivot, eulerAngles);Parameters:
-
point: The point to rotate. -
pivot: The pivot point for the rotation. -
eulerAngles: The Euler angles to rotate the point by.
Returns:
-
rotatedPoint: The rotated point.