Introduced basic Transform classes

This commit is contained in:
Mike Smith 2016-02-07 10:38:17 -08:00
parent 6288a63fdd
commit 60286df583
7 changed files with 145 additions and 3 deletions

View File

@ -45,11 +45,15 @@
<Compile Include="Solids\Cube.cs" /> <Compile Include="Solids\Cube.cs" />
<Compile Include="Solids\Cylinder.cs" /> <Compile Include="Solids\Cylinder.cs" />
<Compile Include="Solids\Sphere.cs" /> <Compile Include="Solids\Sphere.cs" />
<Compile Include="Transforms\ColoredObject.cs" />
<Compile Include="Transforms\MirroredObject.cs" />
<Compile Include="Transforms\ResizedObject.cs" />
<Compile Include="Transforms\RotatedObject.cs" />
<Compile Include="Transforms\ScaledObject.cs" />
<Compile Include="Transforms\TranslatedObject.cs" />
<Compile Include="Vector3.cs" /> <Compile Include="Vector3.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup />
<Folder Include="Transforms\" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets. Other similar extension points exist, see Microsoft.Common.targets.

View File

@ -0,0 +1,24 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace OSCADSharp.Transforms
{
/// <summary>
/// An object that has color and/or opacity applied to it
/// </summary>
public class ColoredObject
{
#region Attributes
public string Color { get; set; } = "Yellow";
public double Opacity { get; set; } = 1.0;
#endregion
public override string ToString()
{
return String.Format("color(\"{0}\", {1})", this.Color, this.Opacity);
}
}
}

View File

@ -0,0 +1,25 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace OSCADSharp.Transforms
{
/// <summary>
/// An object that's mirrored on a plane
/// </summary>
public class MirroredObject
{
/// <summary>
/// The normal vector of a plane intersecting the origin of the object,
/// through which to mirror it.
/// </summary>
public Vector3 Normal { get; set; } = new Vector3();
public override string ToString()
{
return String.Format("mirror([{0}, {1}, {2}])", this.Normal.X, this.Normal.Y, this.Normal.Z);
}
}
}

View File

@ -0,0 +1,22 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace OSCADSharp.Transforms
{
/// <summary>
/// An object that's been resized to a specified set of X/Y/Z dimensions
/// </summary>
public class ResizedObject
{
public Vector3 Size { get; set; }
public override string ToString()
{
return String.Format("resize([{0}, {1}, {2}])", this.Size.X.ToString(),
this.Size.Y.ToString(), this.Size.Z.ToString());
}
}
}

View File

@ -0,0 +1,22 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace OSCADSharp.Transforms
{
/// <summary>
/// An object with rotation applied
/// </summary>
public class RotatedObject
{
public Vector3 Angle { get; set; } = new Vector3();
public override string ToString()
{
return String.Format("rotate([{0}, {1}, {2}])",
this.Angle.X.ToString(), this.Angle.Y.ToString(), this.Angle.Z.ToString());
}
}
}

View File

@ -0,0 +1,22 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace OSCADSharp.Transforms
{
/// <summary>
/// An object that's been rescaled
/// </summary>
public class ScaledObject
{
public Vector3 Scale { get; set; } = new Vector3(1, 1, 1);
public override string ToString()
{
return String.Format("scale(v = [{0}, {1}, {2}])",
this.Scale.X.ToString(), this.Scale.Y.ToString(), this.Scale.Z.ToString());
}
}
}

View File

@ -0,0 +1,23 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace OSCADSharp.Transforms
{
/// <summary>
/// An object or objects that have been moved along the specified vector
/// </summary>
public class TranslatedObject
{
public Vector3 Vector { get; set; }
public override string ToString()
{
return String.Format("translate(v = [{0}, {1}, {2}])",
this.Vector.X.ToString(), this.Vector.Y.ToString(), this.Vector.Z.ToString());
}
}
}