0

Specifically working with DevDept.Geometry inside a VB.Net application. I created a new matrix

Now I want to populate the matrix with values? Any help would be appreciated.

In Visual Studio vb.net, after creating the matrix variable named NormalVectorRotationMatrix from devDept.Geometry class, I type "NormalVectorRotationMatrix." and it only shows 4 methods []Equals,[]GetHashcode, []GetType, []ToString

I expected to see a list of properties/methods to define the size of the matrix and then a list of elements to populate with values. What am I missing?

Dim NormalVectorRotationMatrix As New devDept.Geometry.Matrix
barbsan
  • 3,418
  • 11
  • 21
  • 28
Phil Bugg
  • 11
  • 1

1 Answers1

0

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)
Franck
  • 4,438
  • 1
  • 28
  • 55
  • Thank you Franck for your valuable input. I will try some of the ideas out and see how they work. I really am simply looking to transform a vector 0,0,1 to a new normal vector based on Yaw,Pitch,Roll from a robot program so that I can draw the normal vectors at each point of the robot program. I have already discovered the equations to create the elements for the transformation matrix so I will use your method above or like you save create my own. Thank you again. Cheers! – Phil Bugg Jun 04 '19 at 18:31
  • @PhilBugg from this comment see the last part of my answer where i updated specifically for vector rotation only – Franck Jun 04 '19 at 18:44
  • Your first notion was correct which is commonly the case. Thank you Franck! – Phil Bugg Jun 05 '19 at 18:19
  • after creating the matrix and the vector, I used transformby TestVector.TransformBy(NormalVectorRotationMatrix) – Phil Bugg Jun 05 '19 at 18:21