Files
speckle-sharp-sdk/tests/Speckle.Objects.Tests.Unit/Geometry/ArcTests.cs
T
Claire Kuang 8a148b892f refactor(objects): removes unused classes and constructors (#151)
* removes unused classes and gh schema constructors

* additional cleanup of backwards compatibility (v2)

* Update Arc.cs

* updates unit tests

* re-adds bbox to box

* updates tests

* pr fixes for backwards compatibility

* Uses a new objects test in Revit for serialization tests

* format

* updates revit model curve class to inherit from curve geometry, and adds deprecated v2 classes

* fixes transform unit tests

* fixes deprecated speckle type

* removes unnecessary new revit curve classes

---------

Co-authored-by: Adam Hathcock <adam@hathcock.uk>
Co-authored-by: Alan Rynne <alan@rynne.es>
2024-11-04 17:05:16 +00:00

88 lines
2.5 KiB
C#

using NUnit.Framework;
using Speckle.Objects.Geometry;
using Speckle.Sdk.Common;
namespace Speckle.Objects.Tests.Unit.Geometry;
[TestFixture, TestOf(typeof(Arc))]
public class ArcTests
{
private Plane TestPlaneCounterClockwise
{
get
{
const string UNITS = Units.Meters;
return new()
{
origin = new Point(0, 0, 0, UNITS),
normal = new Vector(0, 0, 1, UNITS),
xdir = new Vector(1, 0, 0, UNITS),
ydir = new Vector(0, 1, 0, UNITS),
units = UNITS,
};
}
}
private Plane TestPlaneClockwise
{
get
{
const string UNITS = Units.Meters;
return new()
{
origin = new Point(0, 0, 0, UNITS),
normal = new Vector(0, 0, -1, UNITS),
xdir = new Vector(-1, 0, 0, UNITS),
ydir = new Vector(0, 1, 0, UNITS),
units = UNITS,
};
}
}
[Test]
public void CanCreateArc_HalfCircle_CounterClockwise()
{
const string UNITS = Units.Meters;
var counterClockwiseArc = new Arc()
{
plane = TestPlaneCounterClockwise,
startPoint = new Point(1, 0, 0, UNITS),
endPoint = new Point(-1, 0, 0, UNITS),
midPoint = new Point(0, 1, 0, UNITS),
units = UNITS,
};
Assert.That(Point.Distance(counterClockwiseArc.midPoint, new Point(0, 1, 0, UNITS)), Is.EqualTo(0).Within(0.0001));
Assert.That(
Point.Distance(counterClockwiseArc.plane.origin, new Point(0, 0, 0, UNITS)),
Is.EqualTo(0).Within(0.0001)
);
Assert.That(counterClockwiseArc.measure - Math.PI, Is.EqualTo(0).Within(0.0001));
Assert.That(counterClockwiseArc.radius, Is.EqualTo(1).Within(0.0001));
Assert.That(counterClockwiseArc.length, Is.EqualTo(Math.PI).Within(0.0001));
}
[Test]
public void CanCreateArc_HalfCircle_Clockwise()
{
const string UNITS = Units.Meters;
var counterClockwiseArc = new Arc()
{
plane = TestPlaneClockwise,
endPoint = new Point(1, 0, 0, UNITS),
startPoint = new Point(-1, 0, 0, UNITS),
midPoint = new Point(0, 1, 0, UNITS),
units = UNITS,
};
Assert.That(Point.Distance(counterClockwiseArc.midPoint, new Point(0, 1, 0, UNITS)), Is.EqualTo(0).Within(0.0001));
Assert.That(
Point.Distance(counterClockwiseArc.plane.origin, new Point(0, 0, 0, UNITS)),
Is.EqualTo(0).Within(0.0001)
);
Assert.That(counterClockwiseArc.measure - Math.PI, Is.EqualTo(0).Within(0.0001));
Assert.That(counterClockwiseArc.radius, Is.EqualTo(1).Within(0.0001));
Assert.That(counterClockwiseArc.length, Is.EqualTo(Math.PI).Within(0.0001));
}
}