Returns two unit vectors (y_axis, z_axis) that together with x_axis (which need not be unit length) form a right-handed orthonormal basis, y = z cross x. With one argument a helper direction is picked automatically; with approximate_axis the z axis is made perpendicular to x_axis and that direction. If the helper is parallel to x_axis another one is substituted.
y, z := make_an_orthonormal_basis(xyz(1, 0, 0));
assert(abs(dot(y, z)) < 0.0001 && abs(dot(y, xyz(1, 0, 0))) < 0.0001);
assert(abs(length(y) - 1) < 0.0001 && abs(length(z) - 1) < 0.0001);make_an_orthonormal_basis :: (
x_axis: Vector3
) -> (y_axis: Vector3, z_axis: Vector3)
Builds two unit axes perpendicular to x_axis and to each other. Picks a reference axis itself.
Parameters
- x_axis: Vector3
- the first axis of the basis.
Returns
make_an_orthonormal_basis :: (
x_axis: Vector3,
approximate_axis: Vector3
) -> (y_axis: Vector3, z_axis: Vector3)
Builds two unit axes perpendicular to x_axis and to each other. The returned z axis is
perpendicular to approximate_axis too, so that axis steers which way the basis points.
Parameters
- x_axis: Vector3
- the first axis of the basis.
- approximate_axis: Vector3
- a rough direction for the y axis. If parallel to
x_axis, another reference is used.