Skip to content

Commit 8021f43

Browse files
committed
Added scale/translation Ray static functions.
1 parent 339fb48 commit 8021f43

3 files changed

Lines changed: 40 additions & 5 deletions

File tree

sources/Maths/Maths/PublicAPI/net10.0/PublicAPI.Unshipped.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1405,11 +1405,15 @@ static Silk.NET.Maths.Ray2D.GetDistanceToRay<T>(this Silk.NET.Maths.Ray2D<T> ray
14051405
static Silk.NET.Maths.Ray2D.GetDistanceToSegment<T>(this Silk.NET.Maths.Ray2D<T> segment, Silk.NET.Maths.Vector2D<T> point) -> T
14061406
static Silk.NET.Maths.Ray2D<T>.operator !=(Silk.NET.Maths.Ray2D<T> left, Silk.NET.Maths.Ray2D<T> right) -> bool
14071407
static Silk.NET.Maths.Ray2D<T>.operator ==(Silk.NET.Maths.Ray2D<T> left, Silk.NET.Maths.Ray2D<T> right) -> bool
1408+
static Silk.NET.Maths.Ray2D<T>.Scale(Silk.NET.Maths.Ray2D<T> value, T scale) -> Silk.NET.Maths.Ray2D<T>
1409+
static Silk.NET.Maths.Ray2D<T>.Translate(Silk.NET.Maths.Ray2D<T> value, Silk.NET.Maths.Vector2D<T> translation) -> Silk.NET.Maths.Ray2D<T>
14081410
static Silk.NET.Maths.Ray3D.GetDistanceToLine<T>(this Silk.NET.Maths.Ray3D<T> line, Silk.NET.Maths.Vector3D<T> point) -> T
14091411
static Silk.NET.Maths.Ray3D.GetDistanceToRay<T>(this Silk.NET.Maths.Ray3D<T> ray, Silk.NET.Maths.Vector3D<T> point) -> T
14101412
static Silk.NET.Maths.Ray3D.GetDistanceToSegment<T>(this Silk.NET.Maths.Ray3D<T> segment, Silk.NET.Maths.Vector3D<T> point) -> T
14111413
static Silk.NET.Maths.Ray3D<T>.operator !=(Silk.NET.Maths.Ray3D<T> left, Silk.NET.Maths.Ray3D<T> right) -> bool
14121414
static Silk.NET.Maths.Ray3D<T>.operator ==(Silk.NET.Maths.Ray3D<T> left, Silk.NET.Maths.Ray3D<T> right) -> bool
1415+
static Silk.NET.Maths.Ray3D<T>.Scale(Silk.NET.Maths.Ray2D<T> value, T scale) -> Silk.NET.Maths.Ray2D<T>
1416+
static Silk.NET.Maths.Ray3D<T>.Translate(Silk.NET.Maths.Ray2D<T> value, Silk.NET.Maths.Vector2D<T> translation) -> Silk.NET.Maths.Ray2D<T>
14131417
static Silk.NET.Maths.Rect2D.FromLTRB<T>(T left, T top, T right, T bottom) -> Silk.NET.Maths.Rect2D<T>
14141418
static Silk.NET.Maths.Rect2D<T>.operator !=(Silk.NET.Maths.Rect2D<T> left, Silk.NET.Maths.Rect2D<T> right) -> bool
14151419
static Silk.NET.Maths.Rect2D<T>.operator ==(Silk.NET.Maths.Rect2D<T> left, Silk.NET.Maths.Rect2D<T> right) -> bool

sources/Maths/Maths/Ray2D.cs

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// The .NET Foundation licenses this file to you under the MIT license.
33

44
using System.Numerics;
5+
using System.Runtime.CompilerServices;
56
using System.Runtime.Serialization;
67

78
namespace Silk.NET.Maths
@@ -78,8 +79,24 @@ public Ray2D(T originX, T originY, T directionX, T directionY)
7879
/// </summary>
7980
/// <param name="distance">The distance along the ray.</param>
8081
/// <returns>A point at a distance along the ray.</returns>
81-
public readonly Vector2D<T> GetPoint(T distance) =>
82-
Origin + (Direction * distance);
82+
public readonly Vector2D<T> GetPoint(T distance)
83+
=> Origin + (Direction * distance);
84+
85+
/// <summary>Scales the Ray.</summary>
86+
/// <param name="value">The ray to scale.</param>
87+
/// <param name="scale">The scaling factor to apply.</param>
88+
/// <returns>The scaled Ray.</returns>
89+
[MethodImpl((MethodImplOptions)768)]
90+
public static Ray2D<T> Scale(Ray2D<T> value, T scale)
91+
=> new(value.Origin * scale, value.Direction * scale);
92+
93+
/// <summary>Translates the Ray.</summary>
94+
/// <param name="value">The ray to translate.</param>
95+
/// <param name="translation">The translation to apply.</param>
96+
/// <returns>The scaled Ray.</returns>
97+
[MethodImpl((MethodImplOptions)768)]
98+
public static Ray2D<T> Translate(Ray2D<T> value, Vector2D<T> translation)
99+
=> new(value.Origin + translation, value.Direction);
83100

84101
/// <summary>Returns a boolean indicating whether the given Ray2D is equal to this Ray2D instance.</summary>
85102
/// <param name="other">The Ray2D to compare this instance to.</param>

sources/Maths/Maths/Ray3D.cs

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,23 @@ public Ray3D(T originX, T originY, T originZ, T directionX, T directionY, T dire
8383
/// <param name="distance">The distance along the ray.</param>
8484
/// <returns>A point at a distance along the ray.</returns>
8585
public readonly Vector3D<T> GetPoint(T distance)
86-
{
87-
return Origin + (Direction * distance);
88-
}
86+
=> Origin + (Direction * distance);
87+
88+
/// <summary>Scales the Ray.</summary>
89+
/// <param name="value">The ray to scale.</param>
90+
/// <param name="scale">The scaling factor to apply.</param>
91+
/// <returns>The scaled Ray.</returns>
92+
[MethodImpl((MethodImplOptions)768)]
93+
public static Ray2D<T> Scale(Ray2D<T> value, T scale)
94+
=> new(value.Origin * scale, value.Direction * scale);
95+
96+
/// <summary>Translates the Ray.</summary>
97+
/// <param name="value">The ray to translate.</param>
98+
/// <param name="translation">The translation to apply.</param>
99+
/// <returns>The scaled Ray.</returns>
100+
[MethodImpl((MethodImplOptions)768)]
101+
public static Ray2D<T> Translate(Ray2D<T> value, Vector2D<T> translation)
102+
=> new(value.Origin + translation, value.Direction);
89103

90104
/// <summary>Returns a boolean indicating whether the given Ray3D is equal to this Ray3D instance.</summary>
91105
/// <param name="other">The Ray3D to compare this instance to.</param>

0 commit comments

Comments
 (0)