mirror of
https://github.com/eliasstepanik/OSCADSharpDotnet7.git
synced 2026-01-12 05:58:34 +00:00
+ Added a NotSupportedException when Position is called on a mirrored object that's been mirrored on multiple axes + test
This commit is contained in:
parent
8e5aa0a2f3
commit
2bbe452da6
@ -31,5 +31,14 @@ namespace OSCADSharp.UnitTests
|
||||
pos.Z = -pos.Z;
|
||||
Assert.AreEqual(pos, zMirror.Position());
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[ExpectedException(typeof(NotSupportedException))]
|
||||
public void Mirror_MultiAxisPositionThrowsNotSupportedException()
|
||||
{
|
||||
var cube = new Cube(5, 10, 20);
|
||||
|
||||
var pos = cube.Mirror(1, 1, 0).Position();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -55,6 +55,11 @@ namespace OSCADSharp.Transforms
|
||||
// fix mirrored positions for multiple-axis mirroring
|
||||
public override Vector3 Position()
|
||||
{
|
||||
if (this.isMoreThanOneAxis())
|
||||
{
|
||||
throw new NotSupportedException("Getting the position of an object that's been mirrored on more than one axis is not currently supported.");
|
||||
}
|
||||
|
||||
var pos = obj.Position();
|
||||
|
||||
double x = this.Normal.X != 0 ? pos.X * -1 : pos.X;
|
||||
@ -63,5 +68,11 @@ namespace OSCADSharp.Transforms
|
||||
|
||||
return new Vector3(x, y, z);
|
||||
}
|
||||
|
||||
private bool isMoreThanOneAxis()
|
||||
{
|
||||
return (this.Normal.X != 0 && (this.Normal.Y != 0 || this.Normal.Z != 0)) ||
|
||||
(this.Normal.Y != 0 && (this.Normal.X != 0 || this.Normal.Z != 0));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user