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:
parent
76eb59f6c5
commit
221ee70f0c
@ -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>
|
||||
|
@ -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>
|
||||
|
Loading…
Reference in New Issue
Block a user