Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#656 Helper constructors #657

Merged
merged 1 commit into from
Oct 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 36 additions & 2 deletions src/Maths/Silk.NET.Maths/Box2D.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,48 @@ public struct Box2D<T>
/// <summary>
/// Constructs a Box2D from a min and a max
/// </summary>
/// <param name="min">The min of the rect.</param>
/// <param name="max">The max of the rect.</param>
/// <param name="min">The min of the box.</param>
/// <param name="max">The max of the box.</param>
public Box2D(Vector2D<T> min, Vector2D<T> max)
{
Min = min;
Max = max;
}

/// <summary>
/// Constructs a Box2D from a min and components of a max
/// </summary>
/// <param name="min">The min of the box.</param>
/// <param name="maxX">The max X component of the box.</param>
/// <param name="maxY">The max Y component of the box.</param>
public Box2D(Vector2D<T> min, T maxX, T maxY)
: this(min, new Vector2D<T>(maxX, maxY))
{
}

/// <summary>
/// Constructs a Box2D from components of a min and a max
/// </summary>
/// <param name="minX">The min X component of the box.</param>
/// <param name="minY">The min Y component of the box.</param>
/// <param name="max">The max of the box.</param>
public Box2D(T minX, T minY, Vector2D<T> max)
: this(new Vector2D<T>(minX, minY), max)
{
}

/// <summary>
/// Constructs a Box2D from components of a min and components of a max
/// </summary>
/// <param name="minX">The min X component of the box.</param>
/// <param name="minY">The min Y component of the box.</param>
/// <param name="maxX">The max X component of the box.</param>
/// <param name="maxY">The max Y component of the box.</param>
public Box2D(T minX, T minY, T maxX, T maxY)
: this(new Vector2D<T>(minX, minY), new Vector2D<T>(maxX, maxY))
{
}

/// <summary>
/// The center of this box.
/// </summary>
Expand Down
42 changes: 40 additions & 2 deletions src/Maths/Silk.NET.Maths/Box3D.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,52 @@ public struct Box3D<T>
/// <summary>
/// Constructs a Box3D from a min and a max
/// </summary>
/// <param name="min">The min of the rect.</param>
/// <param name="max">The max of the rect.</param>
/// <param name="min">The min of the box.</param>
/// <param name="max">The max of the box.</param>
public Box3D(Vector3D<T> min, Vector3D<T> max)
{
Min = min;
Max = max;
}

/// <summary>
/// Constructs a Box3D from a min and components of a max
/// </summary>
/// <param name="min">The min of the box.</param>
/// <param name="maxX">The max X component of the box.</param>
/// <param name="maxY">The max Y component of the box.</param>
/// <param name="maxZ">The max Z component of the box.</param>
public Box3D(Vector3D<T> min, T maxX, T maxY, T maxZ)
: this(min, new Vector3D<T>(maxX, maxY, maxZ))
{
}

/// <summary>
/// Constructs a Box3D from components of a min and a max
/// </summary>
/// <param name="minX">The min X component of the box.</param>
/// <param name="minY">The min Y component of the box.</param>
/// <param name="minZ">The min Z component of the box.</param>
/// <param name="max">The max of the box.</param>
public Box3D(T minX, T minY, T minZ, Vector3D<T> max)
: this(new Vector3D<T>(minX, minY, minZ), max)
{
}

/// <summary>
/// Constructs a Box3D from components of a min and a max
/// </summary>
/// <param name="minX">The min X component of the box.</param>
/// <param name="minY">The min Y component of the box.</param>
/// <param name="minZ">The min Z component of the box.</param>
/// <param name="maxX">The max X component of the box.</param>
/// <param name="maxY">The max Y component of the box.</param>
/// <param name="maxZ">The max Z component of the box.</param>
public Box3D(T minX, T minY, T minZ, T maxX, T maxY, T maxZ)
: this(new Vector3D<T>(minX, minY, minZ), new Vector3D<T>(maxX, maxY, maxZ))
{
}

/// <summary>
/// The center of this box.
/// </summary>
Expand Down
11 changes: 11 additions & 0 deletions src/Maths/Silk.NET.Maths/Circle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,17 @@ public Circle(Vector2D<T> center, T radius)
Radius = radius;
}

/// <summary>
/// Constructs a circle from components of a center and a <paramref name="radius"/>
/// </summary>
/// <param name="centerX">The X component of the center.</param>
/// <param name="centerY">The Y component of the center.</param>
/// <param name="radius">The radius.</param>
public Circle(T centerX, T centerY, T radius)
: this(new Vector2D<T>(centerX, centerY), radius)
{
}

/// <summary>
/// The diameter.
/// </summary>
Expand Down
40 changes: 39 additions & 1 deletion src/Maths/Silk.NET.Maths/Cube.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public struct Cube<T>
public Vector3D<T> Size;

/// <summary>
/// Constructs a Cube from an origin and it's size
/// Constructs a Cube from an origin and a size
/// </summary>
/// <param name="origin">The origin of the cube.</param>
/// <param name="size">The size of the cube.</param>
Expand All @@ -38,6 +38,44 @@ public Cube(Vector3D<T> origin, Vector3D<T> size)
Size = size;
}

/// <summary>
/// Constructs a Cube from an origin and components of a size
/// </summary>
/// <param name="origin">The origin of the cube.</param>
/// <param name="sizeX">The X component of the size of the cube.</param>
/// <param name="sizeY">The Y component of the size of the cube.</param>
/// <param name="sizeZ">The Z component of the size of the cube.</param>
public Cube(Vector3D<T> origin, T sizeX, T sizeY, T sizeZ)
: this(origin, new Vector3D<T>(sizeX, sizeY, sizeZ))
{
}

/// <summary>
/// Constructs a Cube from components of an origin and a size
/// </summary>
/// <param name="originX">The X component of the origin of the cube.</param>
/// <param name="originY">The Y component of the origin of the cube.</param>
/// <param name="originZ">The Z component of the origin of the cube.</param>
/// <param name="size">The size of the cube.</param>
public Cube(T originX, T originY, T originZ, Vector3D<T> size)
: this(new Vector3D<T>(originX, originY, originZ), size)
{
}

/// <summary>
/// Constructs a Cube from components of an origin and components of a size
/// </summary>
/// <param name="originX">The X component of the origin of the cube.</param>
/// <param name="originY">The Y component of the origin of the cube.</param>
/// <param name="originZ">The Z component of the origin of the cube.</param>
/// <param name="sizeX">The X component of the size of the cube.</param>
/// <param name="sizeY">The Y component of the size of the cube.</param>
/// <param name="sizeZ">The Z component of the size of the cube.</param>
public Cube(T originX, T originY, T originZ, T sizeX, T sizeY, T sizeZ)
: this(new Vector3D<T>(originX, originY, originZ), new Vector3D<T>(sizeX, sizeY, sizeZ))
{
}

/// <summary>
/// The center of this cube.
/// </summary>
Expand Down
20 changes: 20 additions & 0 deletions src/Maths/Silk.NET.Maths/PublicAPI.Shipped.txt
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ override Silk.NET.Maths.Vector4D<T>.ToString() -> string!
Silk.NET.Maths.Box2D<T>
Silk.NET.Maths.Box2D<T>.Box2D() -> void
Silk.NET.Maths.Box2D<T>.Box2D(Silk.NET.Maths.Vector2D<T> min, Silk.NET.Maths.Vector2D<T> max) -> void
Silk.NET.Maths.Box2D<T>.Box2D(Silk.NET.Maths.Vector2D<T> min, T maxX, T maxY) -> void
Silk.NET.Maths.Box2D<T>.Box2D(T minX, T minY, Silk.NET.Maths.Vector2D<T> max) -> void
Silk.NET.Maths.Box2D<T>.Box2D(T minX, T minY, T maxX, T maxY) -> void
Silk.NET.Maths.Box2D<T>.Center.get -> Silk.NET.Maths.Vector2D<T>
Silk.NET.Maths.Box2D<T>.Contains(Silk.NET.Maths.Box2D<T> other) -> bool
Silk.NET.Maths.Box2D<T>.Contains(Silk.NET.Maths.Vector2D<T> point) -> bool
Expand All @@ -74,6 +77,9 @@ Silk.NET.Maths.Box2D<T>.Size.get -> Silk.NET.Maths.Vector2D<T>
Silk.NET.Maths.Box3D<T>
Silk.NET.Maths.Box3D<T>.Box3D() -> void
Silk.NET.Maths.Box3D<T>.Box3D(Silk.NET.Maths.Vector3D<T> min, Silk.NET.Maths.Vector3D<T> max) -> void
Silk.NET.Maths.Box3D<T>.Box3D(Silk.NET.Maths.Vector3D<T> min, T maxX, T maxY, T maxZ) -> void
Silk.NET.Maths.Box3D<T>.Box3D(T minX, T minY, T minZ, Silk.NET.Maths.Vector3D<T> max) -> void
Silk.NET.Maths.Box3D<T>.Box3D(T minX, T minY, T minZ, T maxX, T maxY, T maxZ) -> void
Silk.NET.Maths.Box3D<T>.Center.get -> Silk.NET.Maths.Vector3D<T>
Silk.NET.Maths.Box3D<T>.Contains(Silk.NET.Maths.Box3D<T> other) -> bool
Silk.NET.Maths.Box3D<T>.Contains(Silk.NET.Maths.Vector3D<T> point) -> bool
Expand All @@ -89,6 +95,7 @@ Silk.NET.Maths.Circle<T>
Silk.NET.Maths.Circle<T>.Center -> Silk.NET.Maths.Vector2D<T>
Silk.NET.Maths.Circle<T>.Circle() -> void
Silk.NET.Maths.Circle<T>.Circle(Silk.NET.Maths.Vector2D<T> center, T radius) -> void
Silk.NET.Maths.Circle<T>.Circle(T centerX, T centerY, T radius) -> void
Silk.NET.Maths.Circle<T>.Circumference.get -> T
Silk.NET.Maths.Circle<T>.Contains(Silk.NET.Maths.Circle<T> other) -> bool
Silk.NET.Maths.Circle<T>.Contains(Silk.NET.Maths.Vector2D<T> point) -> bool
Expand All @@ -106,6 +113,9 @@ Silk.NET.Maths.Cube<T>.Contains(Silk.NET.Maths.Cube<T> other) -> bool
Silk.NET.Maths.Cube<T>.Contains(Silk.NET.Maths.Vector3D<T> point) -> bool
Silk.NET.Maths.Cube<T>.Cube() -> void
Silk.NET.Maths.Cube<T>.Cube(Silk.NET.Maths.Vector3D<T> origin, Silk.NET.Maths.Vector3D<T> size) -> void
Silk.NET.Maths.Cube<T>.Cube(Silk.NET.Maths.Vector3D<T> origin, T sizeX, T sizeY, T sizeZ) -> void
Silk.NET.Maths.Cube<T>.Cube(T originX, T originY, T originZ, Silk.NET.Maths.Vector3D<T> size) -> void
Silk.NET.Maths.Cube<T>.Cube(T originX, T originY, T originZ, T sizeX, T sizeY, T sizeZ) -> void
Silk.NET.Maths.Cube<T>.Equals(Silk.NET.Maths.Cube<T> other) -> bool
Silk.NET.Maths.Cube<T>.GetDistanceToNearestEdge(Silk.NET.Maths.Vector3D<T> point) -> T
Silk.NET.Maths.Cube<T>.GetInflated(Silk.NET.Maths.Vector3D<T> point) -> Silk.NET.Maths.Cube<T>
Expand Down Expand Up @@ -495,13 +505,19 @@ Silk.NET.Maths.Ray2D<T>.GetPoint(T distance) -> Silk.NET.Maths.Vector2D<T>
Silk.NET.Maths.Ray2D<T>.Origin -> Silk.NET.Maths.Vector2D<T>
Silk.NET.Maths.Ray2D<T>.Ray2D() -> void
Silk.NET.Maths.Ray2D<T>.Ray2D(Silk.NET.Maths.Vector2D<T> origin, Silk.NET.Maths.Vector2D<T> direction) -> void
Silk.NET.Maths.Ray2D<T>.Ray2D(Silk.NET.Maths.Vector2D<T> origin, T directionX, T directionY) -> void
Silk.NET.Maths.Ray2D<T>.Ray2D(T originX, T originY, Silk.NET.Maths.Vector2D<T> direction) -> void
Silk.NET.Maths.Ray2D<T>.Ray2D(T originX, T originY, T directionX, T directionY) -> void
Silk.NET.Maths.Ray3D<T>
Silk.NET.Maths.Ray3D<T>.Direction -> Silk.NET.Maths.Vector3D<T>
Silk.NET.Maths.Ray3D<T>.Equals(Silk.NET.Maths.Ray3D<T> other) -> bool
Silk.NET.Maths.Ray3D<T>.GetPoint(T distance) -> Silk.NET.Maths.Vector3D<T>
Silk.NET.Maths.Ray3D<T>.Origin -> Silk.NET.Maths.Vector3D<T>
Silk.NET.Maths.Ray3D<T>.Ray3D() -> void
Silk.NET.Maths.Ray3D<T>.Ray3D(Silk.NET.Maths.Vector3D<T> origin, Silk.NET.Maths.Vector3D<T> direction) -> void
Silk.NET.Maths.Ray3D<T>.Ray3D(Silk.NET.Maths.Vector3D<T> origin, T directionX, T directionY, T directionZ) -> void
Silk.NET.Maths.Ray3D<T>.Ray3D(T originX, T originY, T originZ, Silk.NET.Maths.Vector3D<T> direction) -> void
Silk.NET.Maths.Ray3D<T>.Ray3D(T originX, T originY, T originZ, T directionX, T directionY, T directionZ) -> void
Silk.NET.Maths.Rectangle
Silk.NET.Maths.Rectangle<T>
Silk.NET.Maths.Rectangle<T>.Center.get -> Silk.NET.Maths.Vector2D<T>
Expand All @@ -517,6 +533,9 @@ Silk.NET.Maths.Rectangle<T>.Max.get -> Silk.NET.Maths.Vector2D<T>
Silk.NET.Maths.Rectangle<T>.Origin -> Silk.NET.Maths.Vector2D<T>
Silk.NET.Maths.Rectangle<T>.Rectangle() -> void
Silk.NET.Maths.Rectangle<T>.Rectangle(Silk.NET.Maths.Vector2D<T> origin, Silk.NET.Maths.Vector2D<T> size) -> void
Silk.NET.Maths.Rectangle<T>.Rectangle(Silk.NET.Maths.Vector2D<T> origin, T sizeX, T sizeY) -> void
Silk.NET.Maths.Rectangle<T>.Rectangle(T originX, T originY, Silk.NET.Maths.Vector2D<T> size) -> void
Silk.NET.Maths.Rectangle<T>.Rectangle(T originX, T originY, T sizeX, T sizeY) -> void
Silk.NET.Maths.Rectangle<T>.Size -> Silk.NET.Maths.Vector2D<T>
Silk.NET.Maths.Scalar
Silk.NET.Maths.Scalar<T>
Expand All @@ -533,6 +552,7 @@ Silk.NET.Maths.Sphere<T>.GetTranslated(Silk.NET.Maths.Vector3D<T> distance) -> S
Silk.NET.Maths.Sphere<T>.Radius -> T
Silk.NET.Maths.Sphere<T>.Sphere() -> void
Silk.NET.Maths.Sphere<T>.Sphere(Silk.NET.Maths.Vector3D<T> center, T radius) -> void
Silk.NET.Maths.Sphere<T>.Sphere(T centerX, T centerY, T centerZ, T radius) -> void
Silk.NET.Maths.Sphere<T>.SquaredRadius.get -> T
Silk.NET.Maths.SystemNumericsExtensions
Silk.NET.Maths.Vector2D
Expand Down
34 changes: 34 additions & 0 deletions src/Maths/Silk.NET.Maths/Ray2D.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,40 @@ public Ray2D(Vector2D<T> origin, Vector2D<T> direction)
Direction = direction;
}

/// <summary>
/// Constructs a Ray using an origin and components of a direction.
/// </summary>
/// <param name="origin">The origin of the ray.</param>
/// <param name="directionX">The X component of the direction of the ray.</param>
/// <param name="directionY">The Y component of the direction of the ray.</param>
public Ray2D(Vector2D<T> origin, T directionX, T directionY)
: this(origin, new Vector2D<T>(directionX, directionY))
{
}

/// <summary>
/// Constructs a Ray using components of an origin and a direction.
/// </summary>
/// <param name="originX">The X component of the origin of the ray.</param>
/// <param name="originY">The Y component of the origin of the ray.</param>
/// <param name="direction">The direction of the ray.</param>
public Ray2D(T originX, T originY, Vector2D<T> direction)
: this(new Vector2D<T>(originX, originY), direction)
{
}

/// <summary>
/// Constructs a Ray using components of an origin and components of a direction.
/// </summary>
/// <param name="originX">The X component of the origin of the ray.</param>
/// <param name="originY">The Y component of the origin of the ray.</param>
/// <param name="directionX">The X component of the direction of the ray.</param>
/// <param name="directionY">The Y component of the direction of the ray.</param>
public Ray2D(T originX, T originY, T directionX, T directionY)
: this(new Vector2D<T>(originX, originY), new Vector2D<T>(directionX, directionY))
{
}

/// <summary>
/// Calculates a point at a distance along the ray.
/// </summary>
Expand Down
38 changes: 38 additions & 0 deletions src/Maths/Silk.NET.Maths/Ray3D.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,44 @@ public Ray3D(Vector3D<T> origin, Vector3D<T> direction)
Direction = direction;
}

/// <summary>
/// Constructs a Ray using an origin and components of a direction.
/// </summary>
/// <param name="origin">The origin of the ray.</param>
/// <param name="directionX">The X component of the direction of the ray.</param>
/// <param name="directionY">The Y component of the direction of the ray.</param>
/// <param name="directionZ">The Z component of the direction of the ray.</param>
public Ray3D(Vector3D<T> origin, T directionX, T directionY, T directionZ)
: this(origin, new Vector3D<T>(directionX, directionY, directionZ))
{
}

/// <summary>
/// Constructs a Ray using components of an origin and a direction.
/// </summary>
/// <param name="originX">The X component of the origin of the ray.</param>
/// <param name="originY">The Y component of the origin of the ray.</param>
/// <param name="originZ">The Z component of the origin of the ray.</param>
/// <param name="direction">The direction of the ray.</param>
public Ray3D(T originX, T originY, T originZ, Vector3D<T> direction)
: this(new Vector3D<T>(originX, originY, originZ), direction)
{
}

/// <summary>
/// Constructs a Ray using components of an origin and components of a direction.
/// </summary>
/// <param name="originX">The X component of the origin of the ray.</param>
/// <param name="originY">The Y component of the origin of the ray.</param>
/// <param name="originZ">The Z component of the origin of the ray.</param>
/// <param name="directionX">The X component of the direction of the ray.</param>
/// <param name="directionY">The Y component of the direction of the ray.</param>
/// <param name="directionZ">The Z component of the direction of the ray.</param>
public Ray3D(T originX, T originY, T originZ, T directionX, T directionY, T directionZ)
: this(new Vector3D<T>(originX, originY, originZ), new Vector3D<T>(directionX, directionY, directionZ))
{
}

/// <summary>
/// Calculates a point at a distance along the ray.
/// </summary>
Expand Down
36 changes: 35 additions & 1 deletion src/Maths/Silk.NET.Maths/Rectangle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public struct Rectangle<T>
public Vector2D<T> Size;

/// <summary>
/// Constructs a Rectangle from an origin and an size
/// Constructs a Rectangle from an origin and a size
/// </summary>
/// <param name="origin">The origin of the rect.</param>
/// <param name="size">The size of the rect.</param>
Expand All @@ -37,6 +37,40 @@ public Rectangle(Vector2D<T> origin, Vector2D<T> size)
Size = size;
}

/// <summary>
/// Constructs a Rectangle from an origin and components of a size
/// </summary>
/// <param name="origin">The origin of the rect.</param>
/// <param name="sizeX">The X component of the size of the rect.</param>
/// <param name="sizeY">The Y component of the size of the rect.</param>
public Rectangle(Vector2D<T> origin, T sizeX, T sizeY)
: this(origin, new Vector2D<T>(sizeX, sizeY))
{
}

/// <summary>
/// Constructs a Rectangle from components of an origin and a size
/// </summary>
/// <param name="originX">The X component of the origin of the rect.</param>
/// <param name="originY">The Y component of the origin of the rect.</param>
/// <param name="size">The size of the rect.</param>
public Rectangle(T originX, T originY, Vector2D<T> size)
: this(new Vector2D<T>(originX, originY), size)
{
}

/// <summary>
/// Constructs a Rectangle from components of an origin and components of a size
/// </summary>
/// <param name="originX">The X component of the origin of the rect.</param>
/// <param name="originY">The Y component of the origin of the rect.</param>
/// <param name="sizeX">The X component of the size of the rect.</param>
/// <param name="sizeY">The Y component of the size of the rect.</param>
public Rectangle(T originX, T originY, T sizeX, T sizeY)
: this(new Vector2D<T>(originX, originY), new Vector2D<T>(sizeX, sizeY))
{
}

/// <summary>
/// The center of this rectangle.
/// </summary>
Expand Down
Loading