feat: added Vector3D.Transform method
This commit is contained in:
@@ -264,6 +264,15 @@ public readonly struct Vector3D(float x, float y, float z) : IEquatable<Vector3D
|
|||||||
/// <returns>The dot product of the two <see cref="Vector3D"/>s.</returns>
|
/// <returns>The dot product of the two <see cref="Vector3D"/>s.</returns>
|
||||||
public static float Dot(Vector3D left, Vector3D right) => left.X * right.X + left.Y * right.Y + left.Z * right.Z;
|
public static float Dot(Vector3D left, Vector3D right) => left.X * right.X + left.Y * right.Y + left.Z * right.Z;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Transforms the <see cref="Vector3D"/> using the specified <see cref="ITransform3D"/>.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="vector">The <see cref="Vector3D"/> to transform.</param>
|
||||||
|
/// <param name="transform">The <see cref="ITransform3D"/> to apply.</param>
|
||||||
|
/// <returns>The transformed <see cref="Vector3D"/>.</returns>
|
||||||
|
public static Vector3D Transform(Vector3D vector, ITransform3D transform)
|
||||||
|
=> Quaternion.RotateVector(vector, transform.Rotation).Add(transform.Position).Scale(transform.Scale);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Checks if two <see cref="Vector3D"/>s are approximately equal within a specified epsilon range.
|
/// Checks if two <see cref="Vector3D"/>s are approximately equal within a specified epsilon range.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -363,6 +372,12 @@ public static class Vector3DExtensions
|
|||||||
/// <inheritdoc cref="Vector3D.Dot(Vector3D, Vector3D)" />
|
/// <inheritdoc cref="Vector3D.Dot(Vector3D, Vector3D)" />
|
||||||
public static float Dot(this Vector3D left, Vector3D right) => Vector3D.Dot(left, right);
|
public static float Dot(this Vector3D left, Vector3D right) => Vector3D.Dot(left, right);
|
||||||
|
|
||||||
|
/// <inheritdoc cref="Vector3D.Transform(Vector3D, ITransform3D)" />
|
||||||
|
public static Vector3D Transform(this Vector3D vector, ITransform3D transform) => Vector3D.Transform(vector, transform);
|
||||||
|
|
||||||
|
/// <inheritdoc cref="Vector3D.Transform(Vector3D, ITransform3D)" />
|
||||||
|
public static Vector3D Transform(this ITransform3D transform, Vector3D vector) => Vector3D.Transform(vector, transform);
|
||||||
|
|
||||||
/// <inheritdoc cref="Vector3D.ApproximatelyEquals(Vector3D, Vector3D, float)" />
|
/// <inheritdoc cref="Vector3D.ApproximatelyEquals(Vector3D, Vector3D, float)" />
|
||||||
public static bool ApproximatelyEquals(this Vector3D left, Vector3D right, float epsilon = float.Epsilon) => Vector3D.ApproximatelyEquals(left, right, epsilon);
|
public static bool ApproximatelyEquals(this Vector3D left, Vector3D right, float epsilon = float.Epsilon) => Vector3D.ApproximatelyEquals(left, right, epsilon);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user