|
2 | 2 | // The .NET Foundation licenses this file to you under the MIT license. |
3 | 3 |
|
4 | 4 | using System.Numerics; |
| 5 | +using System.Runtime.CompilerServices; |
5 | 6 | using System.Runtime.Serialization; |
6 | 7 |
|
7 | 8 | namespace Silk.NET.Maths |
@@ -78,8 +79,24 @@ public Ray2D(T originX, T originY, T directionX, T directionY) |
78 | 79 | /// </summary> |
79 | 80 | /// <param name="distance">The distance along the ray.</param> |
80 | 81 | /// <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); |
83 | 100 |
|
84 | 101 | /// <summary>Returns a boolean indicating whether the given Ray2D is equal to this Ray2D instance.</summary> |
85 | 102 | /// <param name="other">The Ray2D to compare this instance to.</param> |
|
0 commit comments