If you want to create an eyeshot matrix it's quite easy. When used you use it through the Transformation
class so you can skip the Matrix
object directly and only use transformations.
You might get mixed up with the fact that the Matrix
class in eyeshot is not an object. It's actually an helper class and the matrix themselves are simply double arrays all the time.
Here an example of 2 different types of matrix you could use and how it works.
// create 2 transformations
var rotation = new devDept.Geometry.Rotation(radian, rotationVector);
var translate = new devDept.Geometry.Translation(x, y, z);
// just a simple object for demonstration purpose
Solid someSolid = Solid.CreateBox(10, 10, 10);
// rotate the solid
someSolid.TransformBy(rotation);
// or translate
someSolid.TransformBy(translate);
// or create a custom transformation (you see the point)
var transformation = rotation * translation * rotation
// apply that custom transformation
someSolid.TransformBy(transformation);
// or even better just create the matrix from scratch
var matrix4x4 = new double[16] {... define 4x4 matrix here ... };
// the transformation object takes a 4x4 double array matrix too
var matrixTransformation = new devDept.Geometry.Transformation(matrix4x4);
If you have worked with the System.Media.Media3D.Matrix3D
or .net then to transform properly that object into a double[]
that will match Eyeshot
format use the following static method
public static double[] ToEyeshotMatrix(this Matrix3D matrix)
{
// this is to format a windows matrix to the proper format eyeshot uses
return new[]
{
matrix.M11,matrix.M21,matrix.M31,matrix.OffsetX,
matrix.M12,matrix.M22,matrix.M32,matrix.OffsetY,
matrix.M13,matrix.M23,matrix.M33,matrix.OffsetZ,
matrix.M14,matrix.M24,matrix.M34,matrix.M44
};
}
// you can call it like so
var someMatrix = System.Media.Media3D.Matrix3D.Identity;
// apply normal .net transform you would do then
var eyeshotMatrix = new devDept.Geometry.Transformation(someMatrix.ToEyeshotMatrix());
This should cover pretty much every way you can work with matrix in eyeshot and .net
As an update to your comment on specific vector manipulation well you don't need eyeshot. You have it in the System.Windows.Media.Media3D
namespace which you need to add reference to PresentationCore
assembly
You do something like this
// create some vector to change
var v = new System.Windows.Media.Media3D.Vector3D(1, 0, 0);
// create a matrix to transform our vector
var m = System.Windows.Media.Media3D.Matrix3D.Identity;
// rotate the matrix in Z 90 degree
m.Rotate(new System.Windows.Media.Media3D.Vector3D(0, 0, 1), 90d);
// apply the matrix to the vector
var resultVector = m.Transform(v);
// resultVector is now (0, 1, 0)