mirror of
https://github.com/eliasstepanik/OSCADSharpDotnet7.git
synced 2026-01-24 11:38:29 +00:00
Fix for an issue where Rotating/Translating an object, then using Scale would yield the wrong Position() value.
This commit is contained in:
parent
f1f699afe4
commit
80c400dee8
@ -13,7 +13,8 @@ namespace OSCADSharp.ConsoleTests
|
|||||||
{
|
{
|
||||||
static void Main(string[] args)
|
static void Main(string[] args)
|
||||||
{
|
{
|
||||||
var obj = new Cube() + new Sphere() + new Sphere().Translate(2, 2, 2) - new Cylinder(2, 5) + new Text3D("Hey hey!");
|
var obj = new Cube(5, 5, 20)
|
||||||
|
.Translate(30, 0, 0).Rotate(0, 90, 0).Scale(2, 2, 2);
|
||||||
|
|
||||||
var pos = obj.Position();
|
var pos = obj.Position();
|
||||||
var cyl1 = new Cylinder(1, 100, true).Translate(pos);
|
var cyl1 = new Cylinder(1, 100, true).Translate(pos);
|
||||||
|
|||||||
@ -65,6 +65,7 @@
|
|||||||
<Compile Include="Booleans\DifferenceTests.cs" />
|
<Compile Include="Booleans\DifferenceTests.cs" />
|
||||||
<Compile Include="Booleans\IntersectionTests.cs" />
|
<Compile Include="Booleans\IntersectionTests.cs" />
|
||||||
<Compile Include="Transforms\MinkowskiTests.cs" />
|
<Compile Include="Transforms\MinkowskiTests.cs" />
|
||||||
|
<Compile Include="Transforms\ScaleTests.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\OSCADSharp\OSCADSharp.csproj">
|
<ProjectReference Include="..\OSCADSharp\OSCADSharp.csproj">
|
||||||
|
|||||||
23
OSCADSharp/OSCADSharp.UnitTests/Transforms/ScaleTests.cs
Normal file
23
OSCADSharp/OSCADSharp.UnitTests/Transforms/ScaleTests.cs
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||||
|
using OSCADSharp.Solids;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace OSCADSharp.UnitTests.Transforms
|
||||||
|
{
|
||||||
|
[TestClass]
|
||||||
|
public class ScaleTests
|
||||||
|
{
|
||||||
|
[TestMethod]
|
||||||
|
public void Scale_TranslateRotateScaleStillYieldsCorrectPosition()
|
||||||
|
{
|
||||||
|
var obj = new Cube(5, 5, 20)
|
||||||
|
.Translate(30, 0, 0).Rotate(0, 90, 0).Scale(2, 2, 2);
|
||||||
|
|
||||||
|
Assert.AreEqual(new Vector3(20, 5, -65), obj.Position());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -51,7 +51,7 @@ namespace OSCADSharp.Transforms
|
|||||||
|
|
||||||
public override Vector3 Position()
|
public override Vector3 Position()
|
||||||
{
|
{
|
||||||
return obj.Position();
|
return obj.Position() * this.ScaleFactor;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user