Click or drag to resize
Ab4d.SharpEngine logo

MathUtilsQuaternionFromTo Method

Creates a quaternion that rotates one direction vector to another.

Namespace: Ab4d.SharpEngine.Utilities
Assembly: Ab4d.SharpEngine (in Ab4d.SharpEngine.dll) Version: 5.0.1075+bc537c8d217949260b11f66ee86aefa6456ac517
Syntax
C#
public static Quaternion QuaternionFromTo(
	Vector3 from,
	Vector3 to,
	bool normalizeInputs = true,
	float epsilon = 1E-06f
)

Parameters

from  Vector3
The direction to rotate from.
to  Vector3
The direction to rotate to.
normalizeInputs  Boolean  (Optional)
true to normalize the input vectors before calculating the rotation; otherwise, the vectors are used as supplied.
epsilon  Single  (Optional)
The tolerance used to detect zero-length vectors and nearly parallel or opposite directions.

Return Value

Quaternion
A quaternion representing the rotation from from to to.
Remarks
When normalizeInputs is false, provide normalized, nonzero direction vectors. Nearly parallel vectors produce the identity quaternion; nearly opposite vectors produce a 180-degree rotation around a perpendicular axis.
See Also