Skip to content

Commit

Permalink
added HorizontalLengthSquared() to Vector3 and fixed MutableAABB retu…
Browse files Browse the repository at this point in the history
…rn types
  • Loading branch information
psu-de committed Mar 27, 2024
1 parent 607e86f commit c196a81
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
10 changes: 3 additions & 7 deletions MineSharp.Core/Geometry/AABB.cs
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ public MutableAABB(double minX, double minY, double minZ, double maxX, double ma
/// Deflate this bounding box by <paramref name="x"/>, <paramref name="y"/>, <paramref name="z"/>
/// Mutates this instance.
/// </summary>
public AABB Deflate(double x, double y, double z)
public MutableAABB Deflate(double x, double y, double z)
{
this.Min.Add(x, y, z);
this.Max.Add(-x, -y, -z);
Expand All @@ -212,7 +212,7 @@ public AABB Deflate(double x, double y, double z)
/// <summary>
/// Expand this bounding box by x, y, z
/// </summary>
public AABB Expand(double x, double y, double z)
public MutableAABB Expand(double x, double y, double z)
{
if (x > 0)
this.Max.Add(x, 0, 0);
Expand All @@ -233,11 +233,7 @@ public AABB Expand(double x, double y, double z)
/// Offset this bounding box by <paramref name="x"/>, <paramref name="y"/>, <paramref name="z"/>.
/// Mutates this instance.
/// </summary>
/// <param name="x"></param>
/// <param name="y"></param>
/// <param name="z"></param>
/// <returns></returns>
public AABB Offset(double x, double y, double z)
public MutableAABB Offset(double x, double y, double z)
{
this.Min.Add(x, y, z);
this.Max.Add(x, y, z);
Expand Down
7 changes: 7 additions & 0 deletions MineSharp.Core/Geometry/Vector3.cs
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,13 @@ public double Length()
public double LengthSquared()
=> this.X * this.X + this.Y * this.Y + this.Z * this.Z;

/// <summary>
/// Calculates the squared horizontal (x, z) length of this vector instance
/// </summary>
[Pure]
public double HorizontalLengthSquared()
=> this.X * this.X + this.Z * this.Z;

/// <summary>
/// Calculates the horizontal squared length of this vector
/// </summary>
Expand Down

0 comments on commit c196a81

Please sign in to comment.