Skip to content

Commit

Permalink
docs(geometry): GeometricVector2
Browse files Browse the repository at this point in the history
  • Loading branch information
jirikostiha committed Apr 19, 2023
1 parent 34d050d commit ae39103
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions src/code/SMath/Geometry2D/GeometricVector2.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,34 +11,40 @@ namespace SMath.Geometry2D
public static class GeometricVector2
{
/// <summary>
/// Vector magnitude/length/size/scalar.
/// Magnitude/length/size/scalar of vector.
/// </summary>
public static class Magnitude
{
/// <summary>
/// Get magnitude of a vector determined by cartesian coordinate system.
/// Calculate magnitude of a vector determined in cartesian coordinate system.
/// </summary>
public static N FromCartesian<N>(N x, N y)
where N : IRootFunctions<N>
=> PT.Hypotenuse(x, y);

/// <summary>
/// Get magnitude of a vector determined by cartesian coordinate system.
/// Calculate magnitude of a vector determined in cartesian coordinate system.
/// </summary>
public static N FromCartesian<N>((N X, N Y) vector)
where N : IRootFunctions<N>
=> PT.Hypotenuse(vector.X, vector.Y);

/// <summary>
/// Calculate magnitude of vectors determined in cartesian coordinate system.
/// </summary>
public static N FromCartesianVectors<N>(params (N X, N Y)[] vectors)
where N : IRootFunctions<N>
=> FromCartesian(Cartesian.FromCartesianVectors(vectors));

/// <summary>
/// Calculate magnitude of two vectors determined in polar coordinate system.
/// </summary>
public static N FromTwoPolarVectors<N>(N magnitude1, N magnitude2, N angle)
where N : ITrigonometricFunctions<N>, IRootFunctions<N>
=> PT.Cosine(magnitude1, magnitude2, -angle);

/// <summary>
/// Magnitude of sum of two polar vectors.
/// Calculate magnitude of sum of two vectors determined in polar coordinate system.
/// </summary>
public static N FromPolarVectors<N>((N Magnitude, N Angle) vector1, (N Magnitude, N Angle) vector2)
where N : ITrigonometricFunctions<N>, IRootFunctions<N>
Expand All @@ -61,7 +67,7 @@ public static N FromPolar<N>(N magnitude, N φ1)
public static class Y
{
/// <summary>
/// Get y-component of vector determined by polar coordinate system.
/// Calculate y-component of vector determined in polar coordinate system.
/// </summary>
public static N FromPolar<N>(N magnitude, N φ1)
where N : ITrigonometricFunctions<N>
Expand All @@ -82,6 +88,9 @@ public static N FromCartesian<N>((N X, N Y) vector)
=> N.Atan(vector.Y / vector.X);
}

/// <summary>
/// Vector in cartesian coordinate system.
/// </summary>
public static class Cartesian
{
public static (N X, N Y) FromPolar<N>(N magnitude, N φ1)
Expand Down Expand Up @@ -118,6 +127,9 @@ public static (N X, N Y) Kvadrantized<N>((N X, N Y) vector)
=> (vector.X / N.Abs(vector.X), vector.Y / N.Abs(vector.Y));
}

/// <summary>
/// Vector in polar coordinate system.
/// </summary>
public static class Polar
{
public static (N Magnitude, N Φ1) FromCartesian<N>(N x, N y)
Expand Down Expand Up @@ -185,7 +197,7 @@ public static N FromPolar<N>((N Radius, N Angle) vector1, (N Radius, N Angle) ve
}

/// <summary>
/// Direction from one to the other vector.
/// Direction from one to the other vector. It is not normalized.
/// </summary>
public static class Direction
{
Expand Down

0 comments on commit ae39103

Please sign in to comment.