mirror of
https://github.com/eliasstepanik/OSCADSharpDotnet7.git
synced 2026-01-11 13:38:33 +00:00
+ Position() on resized objects is now supported via the averaging of Bounds() positions.
This commit is contained in:
parent
62a0a034a1
commit
4527a3cd33
@ -13,7 +13,9 @@ namespace OSCADSharp.ConsoleTests
|
||||
{
|
||||
static void Main(string[] args)
|
||||
{
|
||||
var obj = new Cube(5, 10, 20) + new Sphere(10).Translate(-10, 5, 0);
|
||||
|
||||
var obj = new Cube(5, 5, 20)
|
||||
.Translate(30, 0, 0).Rotate(0, 90, 0).Resize(2, 2, 2);
|
||||
|
||||
var pos = obj.Position();
|
||||
var cyl1 = new Cylinder(1, 100, true).Translate(pos);
|
||||
|
||||
@ -12,11 +12,12 @@ namespace OSCADSharp.UnitTests.Transforms
|
||||
public class ResizeTests
|
||||
{
|
||||
[TestMethod]
|
||||
[ExpectedException(typeof(NotSupportedException))]
|
||||
public void Resize_PositionNotSupportedAfterResize()
|
||||
public void Resize_BoundaryBasedPositionAfterResizeIsInExpectedLocation()
|
||||
{
|
||||
var pos = new Cube(5, 5, 20)
|
||||
.Translate(30, 0, 0).Rotate(0, 90, 0).Resize(2, 2, 2).Position();
|
||||
|
||||
Assert.AreEqual(new Vector3(1, 1, -13), pos);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
|
||||
@ -50,7 +50,8 @@ namespace OSCADSharp.Transforms
|
||||
|
||||
public override Vector3 Position()
|
||||
{
|
||||
throw new NotSupportedException("Position is not supported on Resized objects.");
|
||||
var bounds = this.Bounds();
|
||||
return Vector3.Average(bounds.BottomLeft, bounds.TopRight);
|
||||
}
|
||||
|
||||
public override Bounds Bounds()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user