Development Merge 2025.04.01 #1
@ -74,6 +74,7 @@ public readonly struct AABB(Vector2D lowerBoundary, Vector2D upperBoundary)
|
||||
/// </summary>
|
||||
/// <param name="left">The first <see cref="AABB"/>.</param>
|
||||
/// <param name="right">The second <see cref="AABB"/>.</param>
|
||||
/// <param name="epsilon">The epsilon range.</param>
|
||||
/// <returns><see cref="true"/> if the <see cref="AABB"/>s are approximately equal; otherwise, <see cref="false"/>.</returns>
|
||||
public static bool ApproximatelyEquals(AABB left, AABB right, float epsilon = float.Epsilon)
|
||||
=> left.LowerBoundary.ApproximatelyEquals(right.LowerBoundary, epsilon) && left.UpperBoundary.ApproximatelyEquals(right.UpperBoundary, epsilon);
|
||||
@ -84,12 +85,9 @@ public readonly struct AABB(Vector2D lowerBoundary, Vector2D upperBoundary)
|
||||
/// </summary>
|
||||
public static class AABBExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts a collection of <see cref="Vector2D"/>s to an <see cref="AABB"/>.
|
||||
/// </summary>
|
||||
/// <param name="vectors">The collection of <see cref="Vector2D"/>s.</param>
|
||||
/// <returns>An <see cref="AABB"/> that bounds all the <see cref="Vector2D"/>s.</returns>
|
||||
/// <inheritdoc cref="AABB.ToAABB" />
|
||||
public static AABB ToAABB(this IEnumerable<Vector2D> vectors) => AABB.FromVectors(vectors);
|
||||
|
||||
/// <inheritdoc cref="AABB.ApproximatelyEquals" />
|
||||
public static bool ApproximatelyEquals(this AABB left, AABB right, float epsilon = float.Epsilon) => AABB.ApproximatelyEquals(left, right, epsilon);
|
||||
}
|
||||
|
@ -72,6 +72,10 @@ public readonly struct Circle(Vector2D center, float radius)
|
||||
/// <summary>
|
||||
/// Checks if two <see cref="Circle"/>s are approximately equal.
|
||||
/// </summary>
|
||||
/// <param name="left">The first <see cref="Circle"/>.</param>
|
||||
/// <param name="right">The second <see cref="Circle"/>.</param>
|
||||
/// <param name="epsilon">The epsilon range.</param>
|
||||
/// <returns><see cref="true"/> if the <see cref="Circle"/>s are approximately equal; otherwise, <see cref="false"/>.</returns>
|
||||
public static bool ApproximatelyEquals(Circle left, Circle right, float epsilon = float.Epsilon)
|
||||
=> left.Center.ApproximatelyEquals(right.Center, epsilon) && left.Radius.ApproximatelyEquals(right.Radius, epsilon);
|
||||
}
|
||||
@ -81,30 +85,21 @@ public readonly struct Circle(Vector2D center, float radius)
|
||||
/// </summary>
|
||||
public static class CircleExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Sets the center of the <see cref="Circle"/>.
|
||||
/// </summary>
|
||||
/// <inheritdoc cref="Circle.SetCenter(Circle, Vector2D)" />
|
||||
public static Circle SetCenter(this Circle circle, Vector2D center) => Circle.SetCenter(circle, center);
|
||||
|
||||
/// <summary>
|
||||
/// Sets the radius of the <see cref="Circle"/>.
|
||||
/// </summary>
|
||||
/// <inheritdoc cref="Circle.SetRadius(Circle, float)" />
|
||||
public static Circle SetRadius(this Circle circle, float radius) => Circle.SetRadius(circle, radius);
|
||||
|
||||
/// <summary>
|
||||
/// Moves the <see cref="Circle"/> by the specified <see cref="Vector2D"/>.
|
||||
/// </summary>
|
||||
/// <inheritdoc cref="Circle.Displace(Circle, Vector2D)" />
|
||||
public static Circle Displace(this Circle circle, Vector2D displaceVector) => Circle.Displace(circle, displaceVector);
|
||||
|
||||
/// <summary>
|
||||
/// Projects the <see cref="Circle"/> onto the specified <see cref="Vector2D"/>.
|
||||
/// </summary>
|
||||
/// <inheritdoc cref="Circle.Project(Circle, Vector2D)" />
|
||||
public static Projection1D ToProjection(this Circle circle, Vector2D projectionVector) => Circle.Project(circle, projectionVector);
|
||||
|
||||
/// <summary>
|
||||
/// Transforms the <see cref="Circle"/> by the specified <see cref="ITransform"/>.
|
||||
/// </summary>
|
||||
/// <inheritdoc cref="Circle.TransformCircle(ITransform, Circle)" />
|
||||
public static Circle TransformCircle(this ITransform transform, Circle circle) => Circle.TransformCircle(transform, circle);
|
||||
|
||||
/// <inheritdoc cref="Circle.ApproximatelyEquals(Circle, Circle, float)" />
|
||||
public static bool ApproximatelyEquals(this Circle left, Circle right, float epsilon = float.Epsilon) => Circle.ApproximatelyEquals(left, right, epsilon);
|
||||
}
|
||||
|
@ -184,44 +184,37 @@ public readonly struct Line2D(Vector2D from, Vector2D to)
|
||||
/// <summary>
|
||||
/// Checks if two <see cref="Line2D"/> segments are approximately equal.
|
||||
/// </summary>
|
||||
/// <param name="left">The first <see cref="Line2D"/>.</param>
|
||||
/// <param name="right">The second <see cref="Line2D"/>.</param>
|
||||
/// <param name="epsilon">The epsilon range.</param>
|
||||
/// <returns><see cref="true"/> if the <see cref="Line2D"/>s are approximately equal; otherwise, <see cref="false"/>.</returns>
|
||||
public static bool ApproximatelyEquals(Line2D left, Line2D right, float epsilon = float.Epsilon)
|
||||
=> left.From.ApproximatelyEquals(right.From, epsilon) && left.To.ApproximatelyEquals(right.To, epsilon);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Provides extension methods for the Line struct.
|
||||
/// Provides extension methods for the <see cref="Line2D"/> struct.
|
||||
/// </summary>
|
||||
public static class Line2DExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Linearly interpolates between the two endpoints of the <see cref="Line2D"/> segment using parameter 't'.
|
||||
/// </summary>
|
||||
/// <inheritdoc cref="Line2D.Lerp(Line2D, float)" />
|
||||
public static Vector2D Lerp(this Line2D line, float t) => Line2D.Lerp(line, t);
|
||||
|
||||
/// <summary>
|
||||
/// The equation of the <see cref="Line2D"/> defined by this <see cref="Line2D"/> segment.
|
||||
/// </summary>
|
||||
/// <inheritdoc cref="Line2D.GetLineEquation(Line2D)" />
|
||||
public static Line2DEquation ToLineEquation(this Line2D line) => Line2D.GetLineEquation(line);
|
||||
|
||||
/// <summary>
|
||||
/// Determines whether the specified <see cref="Vector2D"/> lies on the <see cref="Line2D"/>.
|
||||
/// </summary>
|
||||
/// <inheritdoc cref="Line2D.Intersects(Line2D, Vector2D)" />
|
||||
public static bool Intersects(this Line2D line, Vector2D point) => Line2D.Intersects(line, point);
|
||||
|
||||
/// <summary>
|
||||
/// Calculates the parameter 't' representing the point's position on the <see cref="Line2D"/> segment.
|
||||
/// </summary>
|
||||
/// <inheritdoc cref="Line2D.GetT(Line2D, Vector2D)" />
|
||||
public static float GetT(this Line2D line, Vector2D point) => Line2D.GetT(line, point);
|
||||
|
||||
/// <summary>
|
||||
/// Checks if the <see cref="Line2D"/> segment intersects with another <see cref="Line2D"/> segment.
|
||||
/// </summary>
|
||||
/// <inheritdoc cref="Line2D.Intersects(Line2D, Line2D)" />
|
||||
public static bool Intersects(this Line2D left, Line2D right) => Line2D.Intersects(left, right);
|
||||
|
||||
/// <summary>
|
||||
/// Determines whether two <see cref="Line2D"/> segments intersect.
|
||||
/// </summary>
|
||||
/// <inheritdoc cref="Line2D.Intersects(Line2D, Line2D, out Vector2D?)" />
|
||||
public static bool Intersects(this Line2D left, Line2D right, [NotNullWhen(returnValue: true)] out Vector2D? point) => Line2D.Intersects(left, right, out point);
|
||||
|
||||
/// <inheritdoc cref="Line2D.ApproximatelyEquals(Line2D, Line2D, float)" />
|
||||
public static bool ApproximatelyEquals(this Line2D left, Line2D right, float epsilon = float.Epsilon) => Line2D.ApproximatelyEquals(left, right, epsilon);
|
||||
}
|
||||
|
@ -45,13 +45,9 @@ public readonly struct Line2DEquation(float slope, float offsetY)
|
||||
/// </summary>
|
||||
public static class Line2DEquationExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Resolves the y-coordinate for a given x-coordinate using the line equation.
|
||||
/// </summary>
|
||||
/// <param name="lineEquation">The line equation to resolve.</param>
|
||||
/// <param name="x">The x-coordinate for which to resolve the y-coordinate.</param>
|
||||
/// <returns>The y-coordinate resolved using the line equation.</returns>
|
||||
/// <inheritdoc cref="Line2DEquation.Resolve(Line2DEquation, float)" />
|
||||
public static float Resolve(this Line2DEquation lineEquation, float x) => Line2DEquation.Resolve(lineEquation, x);
|
||||
|
||||
/// <inheritdoc cref="Line2DEquation.ApproximatelyEquals(Line2DEquation, Line2DEquation, float)" />
|
||||
public static bool ApproximatelyEquals(this Line2DEquation left, Line2DEquation right, float epsilon = float.Epsilon) => Line2DEquation.ApproximatelyEquals(left, right, epsilon);
|
||||
}
|
||||
|
@ -77,20 +77,9 @@ public readonly struct Projection1D(float min, float max)
|
||||
/// </summary>
|
||||
public static class Projection1DExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Checks if two projections overlap.
|
||||
/// </summary>
|
||||
/// <param name="left">The first projection to check.</param>
|
||||
/// <param name="right">The second projection to check.</param>
|
||||
/// <returns><see cref="true"/> if the projections overlap; otherwise, <see cref="false"/>.</returns>
|
||||
/// <inheritdoc cref="Projection1D.Overlaps(Projection1D, Projection1D)" />
|
||||
public static bool Overlaps(this Projection1D left, Projection1D right) => Projection1D.Overlaps(left, right);
|
||||
|
||||
/// <summary>
|
||||
/// Checks if two projections overlap and calculates the depth of the overlap.
|
||||
/// </summary>
|
||||
/// <param name="left">The first projection to check.</param>
|
||||
/// <param name="right">The second projection to check.</param>
|
||||
/// <param name="depth">The depth of the overlap, if any.</param>
|
||||
/// <returns><see cref="true"/> if the projections overlap; otherwise, <see cref="false"/>.</returns>
|
||||
/// <inheritdoc cref="Projection1D.Overlaps(Projection1D, Projection1D, out float)" />
|
||||
public static bool Overlaps(this Projection1D left, Projection1D right, out float depth) => Projection1D.Overlaps(left, right, out depth);
|
||||
}
|
||||
|
@ -252,121 +252,48 @@ public readonly struct Quaternion(float x, float y, float z, float w)
|
||||
/// </summary>
|
||||
public static class QuaternionExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Calculates the length of the <see cref="Quaternion"/>.
|
||||
/// </summary>
|
||||
/// <param name="quaternion">The <see cref="Quaternion"/>.</param>
|
||||
/// <returns>The length of the <see cref="Quaternion"/>.</returns>
|
||||
/// <inheritdoc cref="Quaternion.Length(Quaternion)" />
|
||||
public static float Length(this Quaternion quaternion) => Quaternion.Length(quaternion);
|
||||
|
||||
/// <summary>
|
||||
/// Calculates the squared length of the <see cref="Quaternion"/>.
|
||||
/// </summary>
|
||||
/// <param name="quaternion">The <see cref="Quaternion"/>.</param>
|
||||
/// <returns>The squared length of the <see cref="Quaternion"/>.</returns>
|
||||
/// <inheritdoc cref="Quaternion.LengthSquared(Quaternion)" />
|
||||
public static float LengthSquared(this Quaternion quaternion) => Quaternion.LengthSquared(quaternion);
|
||||
|
||||
/// <summary>
|
||||
/// Adds two <see cref="Quaternion"/>s.
|
||||
/// </summary>
|
||||
/// <param name="left">The first <see cref="Quaternion"/>.</param>
|
||||
/// <param name="right">The second <see cref="Quaternion"/>.</param>
|
||||
/// <returns>The sum of the two <see cref="Quaternion"/>s.</returns>
|
||||
/// <inheritdoc cref="Quaternion.Add(Quaternion, Quaternion)" />
|
||||
public static Quaternion Add(this Quaternion left, Quaternion right) => Quaternion.Add(left, right);
|
||||
|
||||
/// <summary>
|
||||
/// Subtracts one <see cref="Quaternion"/> from another.
|
||||
/// </summary>
|
||||
/// <param name="left">The <see cref="Quaternion"/> to subtract from.</param>
|
||||
/// <param name="right">The <see cref="Quaternion"/> to subtract.</param>
|
||||
/// <returns>The result of subtracting the second <see cref="Quaternion"/> from the first.</returns>
|
||||
/// <inheritdoc cref="Quaternion.Subtract(Quaternion, Quaternion)" />
|
||||
public static Quaternion Subtract(this Quaternion left, Quaternion right) => Quaternion.Subtract(left, right);
|
||||
|
||||
/// <summary>
|
||||
/// Multiplies a <see cref="Quaternion"/> by a scalar value.
|
||||
/// </summary>
|
||||
/// <param name="quaternion">The <see cref="Quaternion"/>.</param>
|
||||
/// <param name="value">The scalar value.</param>
|
||||
/// <returns>The result of multiplying the <see cref="Quaternion"/> by the scalar value.</returns>
|
||||
/// <inheritdoc cref="Quaternion.Multiply(Quaternion, float)" />
|
||||
public static Quaternion Multiply(this Quaternion quaternion, float value) => Quaternion.Multiply(quaternion, value);
|
||||
|
||||
/// <summary>
|
||||
/// Divides a <see cref="Quaternion"/> by a scalar value.
|
||||
/// </summary>
|
||||
/// <param name="quaternion">The <see cref="Quaternion"/>.</param>
|
||||
/// <param name="value">The scalar value.</param>
|
||||
/// <returns>The result of dividing the <see cref="Quaternion"/> by the scalar value.</returns>
|
||||
/// <inheritdoc cref="Quaternion.Divide(Quaternion, float)" />
|
||||
public static Quaternion Divide(this Quaternion quaternion, float value) => Quaternion.Divide(quaternion, value);
|
||||
|
||||
/// <summary>
|
||||
/// Normalizes the <see cref="Quaternion"/> (creates a unit <see cref="Quaternion"/> with the same direction).
|
||||
/// </summary>
|
||||
/// <param name="quaternion">The <see cref="Quaternion"/> to normalize.</param>
|
||||
/// <returns>The normalized <see cref="Quaternion"/>.</returns>
|
||||
/// <inheritdoc cref="Quaternion.Normalize(Quaternion)" />
|
||||
public static Quaternion Normalize(this Quaternion quaternion) => Quaternion.Normalize(quaternion);
|
||||
|
||||
/// <summary>
|
||||
/// Inverts the direction of the <see cref="Quaternion"/>.
|
||||
/// </summary>
|
||||
/// <param name="quaternion">The <see cref="Quaternion"/>.</param>
|
||||
/// <returns>The inverted <see cref="Quaternion"/>.</returns>
|
||||
/// <inheritdoc cref="Quaternion.Invert(Quaternion)" />
|
||||
public static Quaternion Invert(this Quaternion quaternion) => Quaternion.Invert(quaternion);
|
||||
|
||||
/// <summary>
|
||||
/// Conjugate of the <see cref="Quaternion"/>.
|
||||
/// </summary>
|
||||
/// <param name="quaternion">The <see cref="Quaternion"/>.</param>
|
||||
/// <returns>The inverted <see cref="Quaternion"/>.</returns>
|
||||
/// <inheritdoc cref="Quaternion.Conjugate(Quaternion)" />
|
||||
public static Quaternion Conjugate(this Quaternion quaternion) => Quaternion.Conjugate(quaternion);
|
||||
|
||||
/// <summary>
|
||||
/// Rotates a <see cref="Vector3D"/> by applying the provided <see cref="Quaternion"/>.
|
||||
/// </summary>
|
||||
/// <param name="vector">The <see cref="Vector3D"/> to be rotated.</param>
|
||||
/// <param name="quaternion">The <see cref="Quaternion"/> to used for applying rotation.</param>
|
||||
/// <returns>The rotated <see cref="Vector3D"/>.</returns>
|
||||
/// <inheritdoc cref="Quaternion.RotateVector(Vector3D, Quaternion)" />
|
||||
public static Vector3D RotateVector(this Vector3D vector, Quaternion quaternion) => Quaternion.RotateVector(vector, quaternion);
|
||||
|
||||
/// <summary>
|
||||
/// Performs spherical linear interpolation between two <see cref="Quaternion"/>s.
|
||||
/// </summary>
|
||||
/// <param name="from">The starting <see cref="Quaternion"/> (t = 0).</param>
|
||||
/// <param name="to">The target <see cref="Quaternion"/> (t = 1).</param>
|
||||
/// <param name="t">The interpolation parameter.</param>
|
||||
/// <returns>The interpolated <see cref="Quaternion"/>.</returns>
|
||||
/// <inheritdoc cref="Quaternion.SLerp(Quaternion, Quaternion, float)" />
|
||||
public static Quaternion SLerp(this Quaternion from, Quaternion to, float t) => Quaternion.SLerp(from, to, t);
|
||||
|
||||
/// <summary>
|
||||
/// Performs linear interpolation between two <see cref="Quaternion"/>s.
|
||||
/// </summary>
|
||||
/// <param name="from">The starting <see cref="Quaternion"/> (t = 0).</param>
|
||||
/// <param name="to">The target <see cref="Quaternion"/> (t = 1).</param>
|
||||
/// <param name="t">The interpolation parameter.</param>
|
||||
/// <returns>The interpolated <see cref="Quaternion"/>.</returns>
|
||||
/// <inheritdoc cref="Quaternion.Lerp(Quaternion, Quaternion, float)" />
|
||||
public static Quaternion Lerp(this Quaternion from, Quaternion to, float t) => Quaternion.Lerp(from, to, t);
|
||||
|
||||
/// <summary>
|
||||
/// Calculates the dot product of two <see cref="Quaternion"/>s.
|
||||
/// </summary>
|
||||
/// <param name="left">The first <see cref="Quaternion"/>.</param>
|
||||
/// <param name="right">The second <see cref="Quaternion"/>.</param>
|
||||
/// <returns>The dot product of the two <see cref="Quaternion"/>s.</returns>
|
||||
/// <inheritdoc cref="Quaternion.Dot(Quaternion, Quaternion)" />
|
||||
public static float Dot(this Quaternion left, Quaternion right) => Quaternion.Dot(left, right);
|
||||
|
||||
/// <summary>
|
||||
/// Calculates the <see cref="Quaternion"/> from given axis and angle.
|
||||
/// </summary>
|
||||
/// <param name="axis">The axis of the rotation in <see cref="Vector3D"/>.</param>
|
||||
/// <param name="angle">The angle in radians.</param>
|
||||
/// <returns>The rotation <see cref="Quaternion"/> calculated by the given parameters.</returns>
|
||||
public static Quaternion CreateRotationFromAxis(this Vector3D axis, float angle) => Quaternion.FromAxisAngle(axis, angle);
|
||||
/// <inheritdoc cref="Quaternion.FromAxisAngle(Vector3D, float)" />
|
||||
public static Quaternion CreateRotation(this Vector3D axis, float angle) => Quaternion.FromAxisAngle(axis, angle);
|
||||
|
||||
/// <summary>
|
||||
/// Checks if two <see cref="Quaternion"/>s are approximately equal within a specified epsilon range.
|
||||
/// </summary>
|
||||
/// <param name="left">The first <see cref="Quaternion"/>.</param>
|
||||
/// <param name="right">The second <see cref="Quaternion"/>.</param>
|
||||
/// <param name="epsilon">The epsilon range.</param>
|
||||
/// <returns><see cref="true"/> if the <see cref="Quaternion"/>s are approximately equal; otherwise, <see cref="false"/>.</returns>
|
||||
/// <inheritdoc cref="Quaternion.ApproximatelyEquals(Quaternion, Quaternion, float)" />
|
||||
public static bool ApproximatelyEquals(this Quaternion left, Quaternion right, float epsilon = float.Epsilon) => Quaternion.ApproximatelyEquals(left, right, epsilon);
|
||||
}
|
||||
|
@ -197,6 +197,7 @@ public readonly struct Shape2D(List<Vector2D> vertices) : IEnumerable<Vector2D>
|
||||
/// </summary>
|
||||
/// <param name="left">The first shape to compare.</param>
|
||||
/// <param name="right">The second shape to compare.</param>
|
||||
/// <param name="epsilon">The epsilon range.</param>
|
||||
/// <returns><c>true</c> if the shapes are approximately equal; otherwise, <c>false</c>.</returns>
|
||||
public static bool ApproximatelyEquals(Shape2D left, Shape2D right, float epsilon = float.Epsilon)
|
||||
{
|
||||
@ -222,65 +223,30 @@ public readonly struct Shape2D(List<Vector2D> vertices) : IEnumerable<Vector2D>
|
||||
/// </summary>
|
||||
public static class Shape2DExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a copy of the shape.
|
||||
/// </summary>
|
||||
/// <param name="shape">The shape to copy.</param>
|
||||
/// <returns>A copy of the input shape.</returns>
|
||||
/// <inheritdoc cref="Shape2D.CreateCopy(Shape2D)" />
|
||||
public static Shape2D CreateCopy(this Shape2D shape) => Shape2D.CreateCopy(shape);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the super triangle that encloses the shape.
|
||||
/// </summary>
|
||||
/// <param name="shape">The shape to enclose.</param>
|
||||
/// <returns>The super triangle that encloses the shape.</returns>
|
||||
/// <inheritdoc cref="Shape2D.GetSuperTriangle(Shape2D)" />
|
||||
public static Triangle ToSuperTriangle(this Shape2D shape) => Shape2D.GetSuperTriangle(shape);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the lines that form the edges of the shape.
|
||||
/// </summary>
|
||||
/// <param name="shape">The shape to get lines from.</param>
|
||||
/// <param name="lines">The list to populate with lines.</param>
|
||||
/// <inheritdoc cref="Shape2D.GetLines(Shape2D, IList{Line2D})" />
|
||||
public static void ToLines(this Shape2D shape, IList<Line2D> lines) => Shape2D.GetLines(shape, lines);
|
||||
|
||||
/// <summary>
|
||||
/// Gets a list of lines that form the edges of the shape.
|
||||
/// </summary>
|
||||
/// <param name="shape">The shape to get lines from.</param>
|
||||
/// <returns>A list of lines that form the edges of the shape.</returns>
|
||||
/// <inheritdoc cref="Shape2D.GetLines(Shape2D)" />
|
||||
public static List<Line2D> ToLines(this Shape2D shape) => Shape2D.GetLines(shape);
|
||||
|
||||
/// <summary>
|
||||
/// Projects the shape onto a vector.
|
||||
/// </summary>
|
||||
/// <param name="shape">The shape to project.</param>
|
||||
/// <param name="projectionVector">The vector to project onto.</param>
|
||||
/// <param name="list">The list to populate with projected values.</param>
|
||||
/// <inheritdoc cref="Shape2D.Project(Shape2D, Vector2D, IList{float})" />
|
||||
public static void ToProjection(this Shape2D shape, Vector2D projectionVector, IList<float> list) => Shape2D.Project(shape, projectionVector, list);
|
||||
|
||||
/// <summary>
|
||||
/// Projects the shape onto a vector.
|
||||
/// </summary>
|
||||
/// <param name="shape">The shape to project.</param>
|
||||
/// <param name="projectionVector">The vector to project onto.</param>
|
||||
/// <returns>The projection of the shape onto the vector.</returns>
|
||||
/// <inheritdoc cref="Shape2D.Project(Shape2D, Vector2D)" />
|
||||
public static Projection1D ToProjection(this Shape2D shape, Vector2D projectionVector) => Shape2D.Project(shape, projectionVector);
|
||||
|
||||
/// <summary>
|
||||
/// Transforms the shape using the specified transform.
|
||||
/// </summary>
|
||||
/// <param name="transform">The transform to apply.</param>
|
||||
/// <param name="shape">The shape to transform.</param>
|
||||
/// <returns>The transformed shape.</returns>
|
||||
/// <inheritdoc cref="Shape2D.TransformShape(Shape2D, ITransform)" />
|
||||
public static Shape2D TransformShape(this ITransform transform, Shape2D shape) => Shape2D.TransformShape(shape, transform);
|
||||
|
||||
/// <summary>
|
||||
/// Transforms the shape using the specified transform.
|
||||
/// </summary>
|
||||
/// <param name="transform">The transform to apply.</param>
|
||||
/// <param name="from">The shape to transform.</param>
|
||||
/// <param name="to">The transformed shape.</param>
|
||||
/// <inheritdoc cref="Shape2D.TransformShape(Shape2D, ITransform, Shape2D)" />
|
||||
public static void TransformShape(this ITransform transform, Shape2D from, ref Shape2D to) => Shape2D.TransformShape(from, transform, ref to);
|
||||
|
||||
/// <inheritdoc cref="Shape2D.ApproximatelyEquals(Shape2D, Shape2D, float)" />
|
||||
public static bool ApproximatelyEquals(this Shape2D left, Shape2D right, float epsilon = float.Epsilon) => Shape2D.ApproximatelyEquals(left, right, epsilon);
|
||||
}
|
||||
|
@ -37,11 +37,19 @@ public readonly struct Triangle(Vector2D A, Vector2D B, Vector2D C)
|
||||
return new(center, Vector2D.Distance(center, triangle.A));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines whether two <see cref="Triangle"/>s are approximately equal.
|
||||
/// </summary>
|
||||
/// <param name="left">The first <see cref="Triangle"/> to compare.</param>
|
||||
/// <param name="right">The second <see cref="Triangle"/> to compare.</param>
|
||||
/// <param name="epsilon">The epsilon range.</param>
|
||||
/// <returns><c>true</c> if the <see cref="Triangle"/>s are approximately equal; otherwise, <c>false</c>.</returns>
|
||||
public static bool ApproximatelyEquals(Triangle left, Triangle right, float epsilon = float.Epsilon)
|
||||
=> left.A.ApproximatelyEquals(right.A, epsilon) && left.B.ApproximatelyEquals(right.B, epsilon) && left.C.ApproximatelyEquals(right.C, epsilon);
|
||||
}
|
||||
|
||||
public static class TriangleExtensions
|
||||
{
|
||||
/// <inheritdoc cref="Triangle.ApproximatelyEquals(Triangle, Triangle, float)" />
|
||||
public static bool ApproximatelyEquals(this Triangle left, Triangle right, float epsilon = float.Epsilon) => Triangle.ApproximatelyEquals(left, right, epsilon);
|
||||
}
|
||||
|
@ -313,191 +313,72 @@ public readonly struct Vector2D(float x, float y)
|
||||
/// </summary>
|
||||
public static class Vector2DExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Returns the <see cref="Vector3D"/> representation of the <see cref="Vector2D"/>.
|
||||
/// </summary>
|
||||
/// <param name="vector">The input <see cref="Vector2D"/>.</param>
|
||||
/// <returns>The <see cref="Vector3D"/> representation of the provided <see cref="Vector2D"/>.</returns>
|
||||
public static Vector3D As3D(this Vector2D vector) => new(vector.X, vector.Y, 0f);
|
||||
|
||||
/// <summary>
|
||||
/// Calculates the length of the <see cref="Vector2D"/>.
|
||||
/// </summary>
|
||||
/// <param name="vector">The input <see cref="Vector2D"/>.</param>
|
||||
/// <returns>The length of the <see cref="Vector2D"/>.</returns>
|
||||
/// <inheritdoc cref="Vector2D.Length(Vector2D)" />
|
||||
public static float Length(this Vector2D vector) => Vector2D.Length(vector);
|
||||
|
||||
/// <summary>
|
||||
/// Calculates the squared length of the <see cref="Vector2D"/>.
|
||||
/// </summary>
|
||||
/// <param name="vector">The input <see cref="Vector2D"/>.</param>
|
||||
/// <returns>The squared length of the <see cref="Vector2D"/>.</returns>
|
||||
/// <inheritdoc cref="Vector2D.LengthSquared(this vector) => Vector2D/>
|
||||
public static float LengthSquared(this Vector2D vector) => Vector2D.LengthSquared(vector);
|
||||
|
||||
/// <summary>
|
||||
/// Calculates the distance between two <see cref="Vector2D"/>s.
|
||||
/// </summary>
|
||||
/// <param name="from">The starting <see cref="Vector2D"/>.</param>
|
||||
/// <param name="to">The ending <see cref="Vector2D"/>.</param>
|
||||
/// <returns>The distance between the two <see cref="Vector2D"/>s.</returns>
|
||||
/// <inheritdoc cref="Vector2D.Distance(Vector2D, Vector2D)" />
|
||||
public static float Distance(this Vector2D from, Vector2D to) => Vector2D.Distance(from, to);
|
||||
|
||||
/// <summary>
|
||||
/// Returns the <see cref="Vector2D"/> with its components inverted.
|
||||
/// </summary>
|
||||
/// <param name="vector">The input <see cref="Vector2D"/>.</param>
|
||||
/// <returns>The inverted <see cref="Vector2D"/>.</returns>
|
||||
/// <inheritdoc cref="Vector2D.Invert(this vector) => Vector2D/>
|
||||
public static Vector2D Invert(this Vector2D vector) => Vector2D.Invert(vector);
|
||||
|
||||
/// <summary>
|
||||
/// Adds two <see cref="Vector2D"/>s component-wise.
|
||||
/// </summary>
|
||||
/// <param name="vector">The first <see cref="Vector2D"/>.</param>
|
||||
/// <param name="vectorToAdd">The vector <see cref="Vector2D"/> to be added.</param>
|
||||
/// <returns>The result of the addition.</returns>
|
||||
/// <inheritdoc cref="Vector2D.Add(Vector2D, Vector2D)" />
|
||||
public static Vector2D Add(this Vector2D vector, Vector2D vectorToAdd) => Vector2D.Add(vector, vectorToAdd);
|
||||
|
||||
/// <summary>
|
||||
/// Subtracts one <see cref="Vector2D"/> from another component-wise.
|
||||
/// </summary>
|
||||
/// <param name="vector">The first <see cref="Vector2D"/>.</param>
|
||||
/// <param name="vectorToSubtract">The <see cref="Vector2D"/> to be subtracted.</param>
|
||||
/// <returns>The result of the subtraction.</returns>
|
||||
/// <inheritdoc cref="Vector2D.Subtract(Vector2D, Vector2D)" />
|
||||
public static Vector2D Subtract(this Vector2D vector, Vector2D vectorToSubtract) => Vector2D.Subtract(vector, vectorToSubtract);
|
||||
|
||||
/// <summary>
|
||||
/// Multiplies a <see cref="Vector2D"/> by a scalar value.
|
||||
/// </summary>
|
||||
/// <param name="vector">The <see cref="Vector2D"/> to multiply.</param>
|
||||
/// <param name="value">The scalar value to multiply with.</param>
|
||||
/// <returns>The result of the multiplication.</returns>
|
||||
/// <inheritdoc cref="Vector2D.Multiply(Vector2D, float)" />
|
||||
public static Vector2D Multiply(this Vector2D vector, float value) => Vector2D.Multiply(vector, value);
|
||||
|
||||
/// <summary>
|
||||
/// Divides a <see cref="Vector2D"/> by a scalar value.
|
||||
/// </summary>
|
||||
/// <param name="vector">The <see cref="Vector2D"/> to divide.</param>
|
||||
/// <param name="value">The scalar value to divide with.</param>
|
||||
/// <returns>The result of the division.</returns>
|
||||
/// <inheritdoc cref="Vector2D.Divide(Vector2D, float)" />
|
||||
public static Vector2D Divide(this Vector2D vector, float value) => Vector2D.Divide(vector, value);
|
||||
|
||||
/// <summary>
|
||||
/// Returns a <see cref="Vector2D"/> with the absolute values of each component.
|
||||
/// </summary>
|
||||
/// <param name="vector">The input <see cref="Vector2D"/>.</param>
|
||||
/// <returns>The <see cref="Vector2D"/> with absolute values.</returns>
|
||||
/// <inheritdoc cref="Vector2D.Abs(Vector2D)" />
|
||||
public static Vector2D Abs(this Vector2D vector) => Vector2D.Abs(vector);
|
||||
|
||||
/// <summary>
|
||||
/// Reflects a <see cref="Vector2D"/> off a surface with the specified normal.
|
||||
/// </summary>
|
||||
/// <param name="vector">The <see cref="Vector2D"/> to reflect.</param>
|
||||
/// <param name="normal">The normal <see cref="Vector2D"/> of the reflecting surface.</param>
|
||||
/// <returns>The reflected <see cref="Vector2D"/>.</returns>
|
||||
/// <inheritdoc cref="Vector2D.Reflect(Vector2D, Vector2D)" />
|
||||
public static Vector2D Reflect(this Vector2D vector, Vector2D normal) => Vector2D.Reflect(vector, normal);
|
||||
|
||||
/// <summary>
|
||||
/// Normalizes the <see cref="Vector2D"/> (creates a <see cref="Vector2D"/> with the same direction but with a length of 1).
|
||||
/// </summary>
|
||||
/// <param name="vector">The input <see cref="Vector2D"/>.</param>
|
||||
/// <returns>The normalized <see cref="Vector2D"/>.</returns>
|
||||
/// <inheritdoc cref="Vector2D.Normalize(Vector2D)" />
|
||||
public static Vector2D Normalize(this Vector2D vector) => Vector2D.Normalize(vector);
|
||||
|
||||
/// <summary>
|
||||
/// Creates a <see cref="Vector2D"/> pointing from one point to another.
|
||||
/// </summary>
|
||||
/// <param name="from">The starting point.</param>
|
||||
/// <param name="to">The ending point.</param>
|
||||
/// <returns>The <see cref="Vector2D"/> pointing from <paramref name="from"/> to <paramref name="to"/>.</returns>
|
||||
/// <inheritdoc cref="Vector2D.FromTo(Vector2D, Vector2D)" />
|
||||
public static Vector2D FromTo(this Vector2D from, Vector2D to) => Vector2D.FromTo(from, to);
|
||||
|
||||
/// <summary>
|
||||
/// Scales a <see cref="Vector2D"/> by another <see cref="Vector2D"/> component-wise.
|
||||
/// </summary>
|
||||
/// <param name="vector">The <see cref="Vector2D"/> to scale.</param>
|
||||
/// <param name="scale">The <see cref="Vector2D"/> containing the scaling factors for each component.</param>
|
||||
/// <returns>The scaled <see cref="Vector2D"/>.</returns>
|
||||
/// <inheritdoc cref="Vector2D.Scale(Vector2D, Vector2D)" />
|
||||
public static Vector2D Scale(this Vector2D vector, Vector2D scale) => Vector2D.Scale(vector, scale);
|
||||
|
||||
/// <summary>
|
||||
/// Calculates the perpendicular <see cref="Vector2D"/> to the given <see cref="Vector2D"/>.
|
||||
/// </summary>
|
||||
/// <param name="vector">The input <see cref="Vector2D"/>.</param>
|
||||
/// <returns>A <see cref="Vector2D"/> perpendicular to the input <see cref="Vector2D"/>.</returns>
|
||||
/// <inheritdoc cref="Vector2D.Perpendicular(Vector2D)" />
|
||||
public static Vector2D Perpendicular(this Vector2D vector) => Vector2D.Perpendicular(vector);
|
||||
|
||||
/// <summary>
|
||||
/// Rotates a <see cref="Vector2D"/> by the specified angle (in radians).
|
||||
/// </summary>
|
||||
/// <param name="vector">The <see cref="Vector2D"/> to rotate.</param>
|
||||
/// <param name="angleInRadian">The angle to rotate by, in radians.</param>
|
||||
/// <returns>The rotated <see cref="Vector2D"/>.</returns>
|
||||
/// <inheritdoc cref="Vector2D.Rotate(Vector2D, float)" />
|
||||
public static Vector2D Rotate(this Vector2D vector, float angleInRadian) => Vector2D.Rotate(vector, angleInRadian);
|
||||
|
||||
/// <summary>
|
||||
/// Returns the component-wise minimum of two <see cref="Vector2D"/>s.
|
||||
/// </summary>
|
||||
/// <param name="left">The first <see cref="Vector2D"/>.</param>
|
||||
/// <param name="right">The second <see cref="Vector2D"/>.</param>
|
||||
/// <returns>The <see cref="Vector2D"/> containing the minimum components from both input <see cref="Vector2D"/>s.</returns>
|
||||
/// <inheritdoc cref="Vector2D.Min(Vector2D, Vector2D)" />
|
||||
public static Vector2D Min(this Vector2D left, Vector2D right) => Vector2D.Min(left, right);
|
||||
|
||||
/// <summary>
|
||||
/// Returns the component-wise maximum of two <see cref="Vector2D"/>s.
|
||||
/// </summary>
|
||||
/// <param name="left">The first <see cref="Vector2D"/>.</param>
|
||||
/// <param name="right">The second <see cref="Vector2D"/>.</param>
|
||||
/// <returns>The <see cref="Vector2D"/> containing the maximum components from both input <see cref="Vector2D"/>s.</returns>
|
||||
/// <inheritdoc cref="Vector2D.Max(Vector2D, Vector2D)" />
|
||||
public static Vector2D Max(this Vector2D left, Vector2D right) => Vector2D.Max(left, right);
|
||||
|
||||
/// <summary>
|
||||
/// Clamps each component of a <see cref="Vector2D"/> between the corresponding component of two other <see cref="Vector2D"/>s.
|
||||
/// </summary>
|
||||
/// <param name="vector">The <see cref="Vector2D"/> to clamp.</param>
|
||||
/// <param name="min">The <see cref="Vector2D"/> representing the minimum values for each component.</param>
|
||||
/// <param name="max">The <see cref="Vector2D"/> representing the maximum values for each component.</param>
|
||||
/// <returns>The clamped <see cref="Vector2D"/>.</returns>
|
||||
/// <inheritdoc cref="Vector2D.Clamp(Vector2D, Vector2D,Vector2D)" />
|
||||
public static Vector2D Clamp(this Vector2D vector, Vector2D min, Vector2D max) => Vector2D.Clamp(vector, min, max);
|
||||
|
||||
/// <summary>
|
||||
/// Linearly interpolates between two <see cref="Vector2D"/>s.
|
||||
/// </summary>
|
||||
/// <param name="from">The start <see cref="Vector2D"/>.</param>
|
||||
/// <param name="to">The end <see cref="Vector2D"/>.</param>
|
||||
/// <param name="t">The interpolation parameter (between 0 and 1).</param>
|
||||
/// <returns>The interpolated <see cref="Vector2D"/>.</returns>
|
||||
/// <inheritdoc cref="Vector2D.Lerp(Vector2D, Vector2D," />
|
||||
public static Vector2D Lerp(this Vector2D from, Vector2D to, float t) => Vector2D.Lerp(from, to, t);
|
||||
|
||||
/// <summary>
|
||||
/// Calculates the cross product of two <see cref="Vector2D"/>s.
|
||||
/// </summary>
|
||||
/// <param name="left">The first <see cref="Vector2D"/>.</param>
|
||||
/// <param name="right">The second <see cref="Vector2D"/>.</param>
|
||||
/// <returns>The cross product of the two <see cref="Vector2D"/>s.</returns>
|
||||
/// <inheritdoc cref="Vector2D.Cross(Vector2D, Vector2D)" />
|
||||
public static float Cross(this Vector2D left, Vector2D right) => Vector2D.Cross(left, right);
|
||||
|
||||
/// <summary>
|
||||
/// Calculates the angle in radians between two <see cref="Vector2D"/>s.
|
||||
/// </summary>
|
||||
/// <param name="left">The first <see cref="Vector2D"/>.</param>
|
||||
/// <param name="right">The second <see cref="Vector2D"/>.</param>
|
||||
/// <returns>The angle between the two <see cref="Vector2D"/>s in radians.</returns>
|
||||
/// <inheritdoc cref="Vector2D.Angle(Vector2D, Vector2D)" />
|
||||
public static float AngleBetween(this Vector2D left, Vector2D right) => Vector2D.Angle(left, right);
|
||||
|
||||
/// <summary>
|
||||
/// Calculates the dot product of two <see cref="Vector2D"/>s.
|
||||
/// </summary>
|
||||
/// <param name="left">The first <see cref="Vector2D"/>.</param>
|
||||
/// <param name="right">The second <see cref="Vector2D"/>.</param>
|
||||
/// <returns>The dot product of the two <see cref="Vector2D"/>s.</returns>
|
||||
/// <inheritdoc cref="Vector2D.Dot(Vector2D, Vector2D)" />
|
||||
public static float Dot(this Vector2D left, Vector2D right) => Vector2D.Dot(left, right);
|
||||
|
||||
/// <summary>
|
||||
/// Checks whether two <see cref="Vector2D"/>s are approximately equal within a certain epsilon range.
|
||||
/// </summary>
|
||||
/// <param name="left">The first <see cref="Vector2D"/>.</param>
|
||||
/// <param name="right">The second <see cref="Vector2D"/>.</param>
|
||||
/// <param name="epsilon">The maximum difference allowed between components.</param>
|
||||
/// <returns>True if the <see cref="Vector2D"/>s are approximately equal, false otherwise.</returns>
|
||||
/// <inheritdoc cref="Vector2D.ApproximatelyEquals(Vector2D, Vector2D, float) " />
|
||||
public static bool ApproximatelyEquals(this Vector2D left, Vector2D right, float epsilon = float.Epsilon) => Vector2D.ApproximatelyEquals(left, right, epsilon);
|
||||
}
|
||||
|
@ -298,185 +298,69 @@ public readonly struct Vector3D(float x, float y, float z)
|
||||
/// </summary>
|
||||
public static class Vector3DExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Returns the <see cref="Vector2D"/> representation of the <see cref="Vector3D"/>.
|
||||
/// </summary>
|
||||
/// <param name="vector">The input <see cref="Vector3D"/>.</param>
|
||||
/// <returns>The <see cref="Vector2D"/> representation of the provided <see cref="Vector3D"/>.</returns>
|
||||
public static Vector2D As2D(this Vector3D vector) => new(vector.X, vector.Y);
|
||||
|
||||
/// <summary>
|
||||
/// Calculates the length of the <see cref="Vector3D"/>.
|
||||
/// </summary>
|
||||
/// <param name="vector">The input <see cref="Vector3D"/>.</param>
|
||||
/// <returns>The length of the <see cref="Vector3D"/>.</returns>
|
||||
/// <inheritdoc cref="Vector3D.Length(Vector3D)" />
|
||||
public static float Length(this Vector3D vector) => Vector3D.Length(vector);
|
||||
|
||||
/// <summary>
|
||||
/// Calculates the squared length of the <see cref="Vector3D"/>.
|
||||
/// </summary>
|
||||
/// <param name="vector">The input <see cref="Vector3D"/>.</param>
|
||||
/// <returns>The squared length of the <see cref="Vector3D"/>.</returns>
|
||||
/// <inheritdoc cref="Vector3D.LengthSquared(Vector3D)" />
|
||||
public static float LengthSquared(this Vector3D vector) => Vector3D.LengthSquared(vector);
|
||||
|
||||
/// <summary>
|
||||
/// Calculates the distance between two <see cref="Vector3D"/>s.
|
||||
/// </summary>
|
||||
/// <param name="from">The starting <see cref="Vector3D"/>.</param>
|
||||
/// <param name="to">The ending <see cref="Vector3D"/>.</param>
|
||||
/// <returns>The distance between the two <see cref="Vector3D"/>s.</returns>
|
||||
/// <inheritdoc cref="Vector3D.Distance(Vector3D, Vector3D)" />
|
||||
public static float Distance(this Vector3D from, Vector3D to) => Vector3D.Distance(from, to);
|
||||
|
||||
/// <summary>
|
||||
/// Returns the <see cref="Vector3D"/> with its components inverted.
|
||||
/// </summary>
|
||||
/// <param name="vector">The input <see cref="Vector3D"/>.</param>
|
||||
/// <returns>The inverted <see cref="Vector3D"/>.</returns>
|
||||
/// <inheritdoc cref="Vector3D.Invert(Vector3D)" />
|
||||
public static Vector3D Invert(this Vector3D vector) => Vector3D.Invert(vector);
|
||||
|
||||
/// <summary>
|
||||
/// Adds two <see cref="Vector3D"/>s component-wise.
|
||||
/// </summary>
|
||||
/// <param name="vector">The first <see cref="Vector3D"/>.</param>
|
||||
/// <param name="vectorToAdd">The vector <see cref="Vector3D"/> to be added.</param>
|
||||
/// <returns>The result of the addition.</returns>
|
||||
/// <inheritdoc cref="Vector3D.Add(Vector3D, Vector3D)" />
|
||||
public static Vector3D Add(this Vector3D vector, Vector3D vectorToAdd) => Vector3D.Add(vector, vectorToAdd);
|
||||
|
||||
/// <summary>
|
||||
/// Subtracts one <see cref="Vector3D"/> from another component-wise.
|
||||
/// </summary>
|
||||
/// <param name="vector">The first <see cref="Vector3D"/>.</param>
|
||||
/// <param name="vectorToSubtract">The <see cref="Vector3D"/> to be subtracted.</param>
|
||||
/// <returns>The result of the subtraction.</returns>
|
||||
/// <inheritdoc cref="Vector3D.Subtract(Vector3D, Vector3D)" />
|
||||
public static Vector3D Subtract(this Vector3D vector, Vector3D vectorToSubtract) => Vector3D.Subtract(vector, vectorToSubtract);
|
||||
|
||||
/// <summary>
|
||||
/// Multiplies a <see cref="Vector3D"/> by a scalar value.
|
||||
/// </summary>
|
||||
/// <param name="vector">The <see cref="Vector3D"/> to multiply.</param>
|
||||
/// <param name="value">The scalar value to multiply with.</param>
|
||||
/// <returns>The result of the multiplication.</returns>
|
||||
/// <inheritdoc cref="Vector3D.Multiply(Vector3D, float)" />
|
||||
public static Vector3D Multiply(this Vector3D vector, float value) => Vector3D.Multiply(vector, value);
|
||||
|
||||
/// <summary>
|
||||
/// Divides a <see cref="Vector3D"/> by a scalar value.
|
||||
/// </summary>
|
||||
/// <param name="vector">The <see cref="Vector3D"/> to divide.</param>
|
||||
/// <param name="value">The scalar value to divide with.</param>
|
||||
/// <returns>The result of the division.</returns>
|
||||
/// <inheritdoc cref="Vector3D.Divide(Vector3D, float)" />
|
||||
public static Vector3D Divide(this Vector3D vector, float value) => Vector3D.Divide(vector, value);
|
||||
|
||||
/// <summary>
|
||||
/// Returns a <see cref="Vector3D"/> with the absolute values of each component.
|
||||
/// </summary>
|
||||
/// <param name="vector">The input <see cref="Vector3D"/>.</param>
|
||||
/// <returns>The <see cref="Vector3D"/> with absolute values.</returns>
|
||||
/// <inheritdoc cref="Vector3D.Abs(Vector3D)" />
|
||||
public static Vector3D Abs(this Vector3D vector) => Vector3D.Abs(vector);
|
||||
|
||||
/// <summary>
|
||||
/// Reflects a <see cref="Vector3D"/> off a surface with the specified normal.
|
||||
/// </summary>
|
||||
/// <param name="vector">The <see cref="Vector3D"/> to reflect.</param>
|
||||
/// <param name="normal">The normal <see cref="Vector3D"/> of the reflecting surface.</param>
|
||||
/// <returns>The reflected <see cref="Vector3D"/>.</returns>
|
||||
/// <inheritdoc cref="Vector3D.Reflect(Vector3D, Vector3D)" />
|
||||
public static Vector3D Reflect(this Vector3D vector, Vector3D normal) => Vector3D.Reflect(vector, normal);
|
||||
|
||||
/// <summary>
|
||||
/// Normalizes the <see cref="Vector3D"/> (creates a <see cref="Vector3D"/> with the same direction but with a length of 1).
|
||||
/// </summary>
|
||||
/// <param name="vector">The input <see cref="Vector3D"/>.</param>
|
||||
/// <returns>The normalized <see cref="Vector3D"/>.</returns>
|
||||
/// <inheritdoc cref="Vector3D.Normalize(Vector3D)" />
|
||||
public static Vector3D Normalize(this Vector3D vector) => Vector3D.Normalize(vector);
|
||||
|
||||
/// <summary>
|
||||
/// Creates a <see cref="Vector3D"/> pointing from one point to another.
|
||||
/// </summary>
|
||||
/// <param name="from">The starting point.</param>
|
||||
/// <param name="to">The ending point.</param>
|
||||
/// <returns>The <see cref="Vector3D"/> pointing from <paramref name="from"/> to <paramref name="to"/>.</returns>
|
||||
/// <inheritdoc cref="Vector3D.FromTo(Vector3D, Vector3D)" />
|
||||
public static Vector3D FromTo(this Vector3D from, Vector3D to) => Vector3D.FromTo(from, to);
|
||||
|
||||
/// <summary>
|
||||
/// Scales a <see cref="Vector3D"/> by another <see cref="Vector3D"/> component-wise.
|
||||
/// </summary>
|
||||
/// <param name="vector">The <see cref="Vector3D"/> to scale.</param>
|
||||
/// <param name="scale">The <see cref="Vector3D"/> containing the scaling factors for each component.</param>
|
||||
/// <returns>The scaled <see cref="Vector3D"/>.</returns>
|
||||
/// <inheritdoc cref="Vector3D.Scale(Vector3D, Vector3D)" />
|
||||
public static Vector3D Scale(this Vector3D vector, Vector3D scale) => Vector3D.Scale(vector, scale);
|
||||
|
||||
/// <summary>
|
||||
/// Rotates a <see cref="Vector3D"/> by the specified angle (in radians).
|
||||
/// </summary>
|
||||
/// <param name="vector">The <see cref="Vector3D"/> to rotate.</param>
|
||||
/// <param name="normal">The <see cref="Vector3D"/> to rotate around.</param>
|
||||
/// <param name="angleInRadian">The angle to rotate by, in radians.</param>
|
||||
/// <returns>The rotated <see cref="Vector3D"/>.</returns>
|
||||
/// <inheritdoc cref="Vector3D.Rotate(Vector3D, Vector3D, float)" />
|
||||
public static Vector3D Rotate(this Vector3D vector, Vector3D normal, float angleInRadian) => Vector3D.Rotate(vector, normal, angleInRadian);
|
||||
|
||||
/// <summary>
|
||||
/// Returns the component-wise minimum of two <see cref="Vector3D"/>s.
|
||||
/// </summary>
|
||||
/// <param name="left">The first <see cref="Vector3D"/>.</param>
|
||||
/// <param name="right">The second <see cref="Vector3D"/>.</param>
|
||||
/// <returns>The <see cref="Vector3D"/> containing the minimum components from both input <see cref="Vector3D"/>s.</returns>
|
||||
/// <inheritdoc cref="Vector3D.Min(Vector3D, Vector3D)" />
|
||||
public static Vector3D Min(this Vector3D left, Vector3D right) => Vector3D.Min(left, right);
|
||||
|
||||
/// <summary>
|
||||
/// Returns the component-wise maximum of two <see cref="Vector3D"/>s.
|
||||
/// </summary>
|
||||
/// <param name="left">The first <see cref="Vector3D"/>.</param>
|
||||
/// <param name="right">The second <see cref="Vector3D"/>.</param>
|
||||
/// <returns>The <see cref="Vector3D"/> containing the maximum components from both input <see cref="Vector3D"/>s.</returns>
|
||||
/// <inheritdoc cref="Vector3D.Max(Vector3D, Vector3D)" />
|
||||
public static Vector3D Max(this Vector3D left, Vector3D right) => Vector3D.Max(left, right);
|
||||
|
||||
/// <summary>
|
||||
/// Clamps each component of a <see cref="Vector3D"/> between the corresponding component of two other <see cref="Vector3D"/>s.
|
||||
/// </summary>
|
||||
/// <param name="vector">The <see cref="Vector3D"/> to clamp.</param>
|
||||
/// <param name="min">The <see cref="Vector3D"/> representing the minimum values for each component.</param>
|
||||
/// <param name="max">The <see cref="Vector3D"/> representing the maximum values for each component.</param>
|
||||
/// <returns>The clamped <see cref="Vector3D"/>.</returns>
|
||||
/// <inheritdoc cref="Vector3D.Clamp(Vector3D, Vector3D, Vector3D)" />
|
||||
public static Vector3D Clamp(this Vector3D vector, Vector3D min, Vector3D max) => Vector3D.Clamp(vector, min, max);
|
||||
|
||||
/// <summary>
|
||||
/// Linearly interpolates between two <see cref="Vector3D"/>s.
|
||||
/// </summary>
|
||||
/// <param name="from">The start <see cref="Vector3D"/>.</param>
|
||||
/// <param name="to">The end <see cref="Vector3D"/>.</param>
|
||||
/// <param name="t">The interpolation parameter (between 0 and 1).</param>
|
||||
/// <returns>The interpolated <see cref="Vector3D"/>.</returns>
|
||||
/// <inheritdoc cref="Vector3D.Lerp(Vector3D, Vector3D, float)" />
|
||||
public static Vector3D Lerp(this Vector3D from, Vector3D to, float t) => Vector3D.Lerp(from, to, t);
|
||||
|
||||
/// <summary>
|
||||
/// Calculates the cross product of two <see cref="Vector3D"/>s.
|
||||
/// </summary>
|
||||
/// <param name="left">The first <see cref="Vector3D"/>.</param>
|
||||
/// <param name="right">The second <see cref="Vector3D"/>.</param>
|
||||
/// <returns>The cross product of the two <see cref="Vector3D"/>s.</returns>
|
||||
/// <inheritdoc cref="Vector3D.Cross(Vector3D, Vector3D)" />
|
||||
public static Vector3D Cross(this Vector3D left, Vector3D right) => Vector3D.Cross(left, right);
|
||||
|
||||
/// <summary>
|
||||
/// Calculates the angle in radians between two <see cref="Vector3D"/>s.
|
||||
/// </summary>
|
||||
/// <param name="left">The first <see cref="Vector3D"/>.</param>
|
||||
/// <param name="right">The second <see cref="Vector3D"/>.</param>
|
||||
/// <returns>The angle between the two <see cref="Vector3D"/>s in radians.</returns>
|
||||
/// <inheritdoc cref="Vector3D.Angle(Vector3D, Vector3D)" />
|
||||
public static float AngleBetween(this Vector3D left, Vector3D right) => Vector3D.Angle(left, right);
|
||||
|
||||
/// <summary>
|
||||
/// Calculates the dot product of two <see cref="Vector3D"/>s.
|
||||
/// </summary>
|
||||
/// <param name="left">The first <see cref="Vector3D"/>.</param>
|
||||
/// <param name="right">The second <see cref="Vector3D"/>.</param>
|
||||
/// <returns>The dot product of the two <see cref="Vector3D"/>s.</returns>
|
||||
/// <inheritdoc cref="Vector3D.Dot(Vector3D, Vector3D)" />
|
||||
public static float Dot(this Vector3D left, Vector3D right) => Vector3D.Dot(left, right);
|
||||
|
||||
/// <summary>
|
||||
/// Checks whether two <see cref="Vector3D"/>s are approximately equal within a certain epsilon range.
|
||||
/// </summary>
|
||||
/// <param name="left">The first <see cref="Vector3D"/>.</param>
|
||||
/// <param name="right">The second <see cref="Vector3D"/>.</param>
|
||||
/// <param name="epsilon">The maximum difference allowed between components.</param>
|
||||
/// <returns>True if the <see cref="Vector3D"/>s are approximately equal, false otherwise.</returns>
|
||||
/// <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);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user