1
0
mirror of https://github.com/oliverbooth/X10D synced 2024-11-23 00:58:48 +00:00

Add Sphere/Cube.Volume property

This commit is contained in:
Oliver Booth 2022-06-01 19:42:51 +01:00
parent 76eb59f6c5
commit 221ee70f0c
No known key found for this signature in database
GPG Key ID: 32A00B35503AF634
2 changed files with 24 additions and 2 deletions

View File

@ -1,4 +1,4 @@
using System.Numerics;
using System.Numerics;
using X10D.Numerics;
namespace X10D.Drawing;
@ -257,6 +257,19 @@ public readonly struct Cuboid : IEquatable<Cuboid>
get => LocalBackBottomRight + Center;
}
/// <summary>
/// Gets the volume of this cuboid.
/// </summary>
/// <value>The volume.</value>
public float Volume
{
get
{
Vector3 size = Size;
return size.X * size.Y * size.Z;
}
}
/// <summary>
/// Returns a value indicating whether two instances of <see cref="Cuboid" /> are not equal.
/// </summary>

View File

@ -53,7 +53,16 @@ public readonly struct Sphere : IEquatable<Sphere>, IComparable<Sphere>, ICompar
public float Radius { get; }
/// <summary>
/// Returns a value indicating whether two instances of <see cref="Cuboid" /> are equal.
/// Gets the volume of this sphere.
/// </summary>
/// <value>The volume.</value>
public float Volume
{
get => (4f / 3f) * MathF.PI * Radius * Radius * Radius;
}
/// <summary>
/// Returns a value indicating whether two instances of <see cref="Sphere" /> are equal.
/// </summary>
/// <param name="left">The first instance.</param>
/// <param name="right">The second instance.</param>