Development Merge 2025.04.01 #1
@ -1,195 +0,0 @@
|
||||
namespace Syntriax.Engine.Core;
|
||||
|
||||
/// <summary>
|
||||
/// Provides extension methods for <see cref="Vector2D"/> type.
|
||||
/// </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>
|
||||
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>
|
||||
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>
|
||||
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>
|
||||
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>
|
||||
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>
|
||||
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>
|
||||
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>
|
||||
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>
|
||||
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>
|
||||
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>
|
||||
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>
|
||||
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>
|
||||
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>
|
||||
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>
|
||||
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>
|
||||
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>
|
||||
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>
|
||||
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>
|
||||
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>
|
||||
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>
|
||||
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>
|
||||
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>
|
||||
public static bool ApproximatelyEquals(this Vector2D left, Vector2D right, float epsilon = float.Epsilon) => Vector2D.ApproximatelyEquals(left, right, epsilon);
|
||||
}
|
@ -1,189 +0,0 @@
|
||||
namespace Syntriax.Engine.Core;
|
||||
|
||||
/// <summary>
|
||||
/// Provides extension methods for <see cref="Vector3D"/> type.
|
||||
/// </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>
|
||||
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>
|
||||
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>
|
||||
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>
|
||||
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>
|
||||
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>
|
||||
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>
|
||||
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>
|
||||
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>
|
||||
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>
|
||||
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>
|
||||
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>
|
||||
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>
|
||||
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>
|
||||
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>
|
||||
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>
|
||||
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>
|
||||
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>
|
||||
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>
|
||||
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>
|
||||
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>
|
||||
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>
|
||||
public static bool ApproximatelyEquals(this Vector3D left, Vector3D right, float epsilon = float.Epsilon) => Vector3D.ApproximatelyEquals(left, right, epsilon);
|
||||
}
|
@ -1,8 +1,6 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
using Syntriax.Engine.Core;
|
||||
|
||||
namespace Syntriax.Engine.Physics2D.Primitives;
|
||||
namespace Syntriax.Engine.Core;
|
||||
|
||||
/// <summary>
|
||||
/// Represents an Axis-Aligned Bounding Box (AABB) in 2D space.
|
@ -1,9 +1,7 @@
|
||||
using System.Diagnostics;
|
||||
|
||||
using Syntriax.Engine.Core;
|
||||
using Syntriax.Engine.Core.Abstract;
|
||||
|
||||
namespace Syntriax.Engine.Physics2D.Primitives;
|
||||
namespace Syntriax.Engine.Core;
|
||||
|
||||
/// <summary>
|
||||
/// Represents a 2D circle.
|
||||
@ -11,7 +9,7 @@ namespace Syntriax.Engine.Physics2D.Primitives;
|
||||
/// <param name="center">The center of the circle.</param>
|
||||
/// <param name="radius">The radius of the circle.</param>
|
||||
/// <remarks>
|
||||
/// Initializes a new instance of the Circle struct with the specified center and radius.
|
||||
/// Initializes a new instance of the <see cref="Circle"/> struct with the specified center and radius.
|
||||
/// </remarks>
|
||||
[DebuggerDisplay("Center: {Center.ToString(),nq}, Radius: {Radius}")]
|
||||
public readonly struct Circle(Vector2D center, float radius)
|
@ -1,18 +1,16 @@
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
|
||||
using Syntriax.Engine.Core;
|
||||
|
||||
namespace Syntriax.Engine.Physics2D.Primitives;
|
||||
namespace Syntriax.Engine.Core;
|
||||
|
||||
/// <summary>
|
||||
/// Represents a 2D line segment defined by two endpoints.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Initializes a new instance of the Line struct with the specified endpoints.
|
||||
/// </remarks>
|
||||
/// <param name="from">The starting point of the <see cref="Line2D"/> segment.</param>
|
||||
/// <param name="to">The ending point of the <see cref="Line2D"/> segment.</param>
|
||||
/// <remarks>
|
||||
/// Initializes a new instance of the <see cref="Line2D"/> struct with the specified endpoints.
|
||||
/// </remarks>
|
||||
[System.Diagnostics.DebuggerDisplay("From: {From.ToString(),nq}, To: {To.ToString(),nq}, Direction: {Direction.ToString(),nq}, Length: {Length}")]
|
||||
public readonly struct Line2D(Vector2D from, Vector2D to)
|
||||
{
|
@ -1,6 +1,4 @@
|
||||
using Syntriax.Engine.Core;
|
||||
|
||||
namespace Syntriax.Engine.Physics2D.Primitives;
|
||||
namespace Syntriax.Engine.Core;
|
||||
|
||||
/// <summary>
|
||||
/// Represents a line equation in the form y = mx + b.
|
@ -1,4 +1,4 @@
|
||||
namespace Syntriax.Engine.Physics2D.Primitives;
|
||||
namespace Syntriax.Engine.Core;
|
||||
|
||||
/// <summary>
|
||||
/// Represents a range of values along a single axis.
|
@ -1,10 +1,8 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
using Syntriax.Engine.Core;
|
||||
using Syntriax.Engine.Core.Abstract;
|
||||
|
||||
namespace Syntriax.Engine.Physics2D.Primitives;
|
||||
namespace Syntriax.Engine.Core;
|
||||
|
||||
/// <summary>
|
||||
/// Represents a shape defined by a collection of vertices.
|
@ -1,8 +1,6 @@
|
||||
using System;
|
||||
|
||||
using Syntriax.Engine.Core;
|
||||
|
||||
namespace Syntriax.Engine.Physics2D.Primitives;
|
||||
namespace Syntriax.Engine.Core;
|
||||
|
||||
[System.Diagnostics.DebuggerDisplay("A: {A.ToString(), nq}, B: {B.ToString(), nq}, B: {C.ToString(), nq}")]
|
||||
public readonly struct Triangle(Vector2D A, Vector2D B, Vector2D C)
|
@ -5,6 +5,11 @@ namespace Syntriax.Engine.Core;
|
||||
/// <summary>
|
||||
/// Represents a two-dimensional vector.
|
||||
/// </summary>
|
||||
/// <param name="x">X position of the <see cref="Vector2D"/>.</param>
|
||||
/// <param name="y">Y position of the <see cref="Vector2D"/>.</param>
|
||||
/// <remarks>
|
||||
/// Initializes a new instance of the <see cref="Vector2D"/> struct with the specified positions.
|
||||
/// </remarks>
|
||||
[System.Diagnostics.DebuggerDisplay("{ToString(),nq}, Length: {Magnitude}, LengthSquared: {MagnitudeSquared}, Normalized: {Normalized.ToString(),nq}")]
|
||||
public readonly struct Vector2D(float x, float y)
|
||||
{
|
||||
@ -300,3 +305,197 @@ public readonly struct Vector2D(float x, float y)
|
||||
/// <returns>A hash code for the <see cref="Vector2D"/>.</returns>
|
||||
public override int GetHashCode() => HashCode.Combine(X, Y);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Provides extension methods for <see cref="Vector2D"/> type.
|
||||
/// </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>
|
||||
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>
|
||||
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>
|
||||
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>
|
||||
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>
|
||||
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>
|
||||
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>
|
||||
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>
|
||||
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>
|
||||
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>
|
||||
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>
|
||||
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>
|
||||
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>
|
||||
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>
|
||||
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>
|
||||
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>
|
||||
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>
|
||||
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>
|
||||
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>
|
||||
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>
|
||||
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>
|
||||
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>
|
||||
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>
|
||||
public static bool ApproximatelyEquals(this Vector2D left, Vector2D right, float epsilon = float.Epsilon) => Vector2D.ApproximatelyEquals(left, right, epsilon);
|
||||
}
|
@ -5,6 +5,12 @@ namespace Syntriax.Engine.Core;
|
||||
/// <summary>
|
||||
/// Represents a three-dimensional vector.
|
||||
/// </summary>
|
||||
/// <param name="x">X position of the <see cref="Vector3D"/>.</param>
|
||||
/// <param name="y">Y position of the <see cref="Vector3D"/>.</param>
|
||||
/// <param name="z">Z position of the <see cref="Vector3D"/>.</param>
|
||||
/// <remarks>
|
||||
/// Initializes a new instance of the <see cref="Vector3D"/> struct with the specified positions.
|
||||
/// </remarks>
|
||||
[System.Diagnostics.DebuggerDisplay("{ToString(),nq}, Length: {Magnitude}, LengthSquared: {MagnitudeSquared}, Normalized: {Normalized.ToString(),nq}")]
|
||||
public readonly struct Vector3D(float x, float y, float z)
|
||||
{
|
||||
@ -284,3 +290,191 @@ public readonly struct Vector3D(float x, float y, float z)
|
||||
/// <returns>A hash code for the <see cref="Vector3D"/>.</returns>
|
||||
public override int GetHashCode() => HashCode.Combine(X, Y, Z);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Provides extension methods for <see cref="Vector3D"/> type.
|
||||
/// </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>
|
||||
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>
|
||||
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>
|
||||
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>
|
||||
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>
|
||||
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>
|
||||
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>
|
||||
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>
|
||||
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>
|
||||
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>
|
||||
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>
|
||||
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>
|
||||
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>
|
||||
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>
|
||||
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>
|
||||
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>
|
||||
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>
|
||||
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>
|
||||
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>
|
||||
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>
|
||||
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>
|
||||
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>
|
||||
public static bool ApproximatelyEquals(this Vector3D left, Vector3D right, float epsilon = float.Epsilon) => Vector3D.ApproximatelyEquals(left, right, epsilon);
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
using Syntriax.Engine.Physics2D.Primitives;
|
||||
using Syntriax.Engine.Core;
|
||||
|
||||
namespace Syntriax.Engine.Physics2D.Abstract;
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
using Syntriax.Engine.Physics2D.Primitives;
|
||||
using Syntriax.Engine.Core;
|
||||
|
||||
namespace Syntriax.Engine.Physics2D.Abstract;
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
using Syntriax.Engine.Core;
|
||||
using Syntriax.Engine.Physics2D.Abstract;
|
||||
using Syntriax.Engine.Physics2D.Primitives;
|
||||
|
||||
namespace Syntriax.Engine.Physics2D;
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
using Syntriax.Engine.Core;
|
||||
using Syntriax.Engine.Physics2D.Abstract;
|
||||
using Syntriax.Engine.Physics2D.Primitives;
|
||||
|
||||
namespace Syntriax.Engine.Physics2D;
|
||||
|
||||
|
@ -1,6 +1,5 @@
|
||||
using Syntriax.Engine.Core;
|
||||
using Syntriax.Engine.Physics2D.Abstract;
|
||||
using Syntriax.Engine.Physics2D.Primitives;
|
||||
|
||||
namespace Syntriax.Engine.Physics2D;
|
||||
|
||||
|
@ -1,5 +1,4 @@
|
||||
using Syntriax.Engine.Core;
|
||||
using Syntriax.Engine.Physics2D.Primitives;
|
||||
|
||||
namespace Syntriax.Engine.Physics2D;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user