Matrix Transforms

Matrix Transforms

phildebrandt
Enthusiast Enthusiast
969 Views
3 Replies
Message 1 of 4

Matrix Transforms

phildebrandt
Enthusiast
Enthusiast

Does anyone know a good source on the web to learn how to use matrix transforms?

 

I've been trying to figure out how to extend the length of a line by a given amount and just can't seem to pin it down. I'm also planning on doing so 3D stuff later on so I'd like to figure out how they work.

0 Likes
Accepted solutions (1)
970 Views
3 Replies
Replies (3)
Message 2 of 4

BobbyC.Jones
Advocate
Advocate

I don't have any links, but I remember finding a lot of good matrix info on directx game programming sites.

 

I haven't worked with lines via the API yet, but with a quick glance my first thought is that you'd need to grab the existing line's points, apply some vector math to get the new end point, create a new line, and delete the previous line.  Hopefully someone with experience can chime in.

 

--
Bobby C. Jones
Message 3 of 4

phildebrandt
Enthusiast
Enthusiast

Yeah, I got that part. It's the vector math part I'm having trouble with. The API has vectors (XYZ class) but they are always vectors from 0,0,0. I'm having trouble figuring out how the transform needs to work.

0 Likes
Message 4 of 4

BobbyC.Jones
Advocate
Advocate
Accepted solution

Well, this example shows one way to lengthen a line.  It doesn't utilize the Line class, just shows the math using the XYZ class.  I would definitely check the Line class for any properties or methods that could help.

 

    public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
    {
      //Create a 'line' from 1,1 to 5,1
      XYZ startPoint = new XYZ(1, 1, 0);
      XYZ endPoint = new XYZ(5, 1, 0);

      //Create a vector that represents the original 'line'
      //and then generate a unit vector from it
      XYZ originalVector = endPoint - startPoint;
      XYZ unitVector = originalVector.Normalize();

      //Generate a vector with a magnitude of the amount
      //to lengthen the 'line'
      double additionalLength = 5;
      XYZ additionalLengthVector = unitVector * additionalLength;

      //Find the new endpoint
      XYZ newEndPoint = endPoint.Add(additionalLengthVector);

      TaskDialog.Show("Lengthen Line Example", "Original endpoint: " + endPoint.ToString() +
                                               "\nNew endpoint: " + newEndPoint.ToString());

      return Result.Succeeded;
    }

 

--
Bobby C. Jones
0 Likes