Cannot figure out how the Transform.CreateRotationAtPoint() works! Help

Cannot figure out how the Transform.CreateRotationAtPoint() works! Help

Anonymous
Not applicable
3,067 Views
2 Replies
Message 1 of 3

Cannot figure out how the Transform.CreateRotationAtPoint() works! Help

Anonymous
Not applicable

I am trying to take an XYZ point and rotate it 1Pi (180 degrees) around another base point. I think I got the correct method but I cannot figure out how to use it. See image attached

 

Base point = XYZ Origin? Is the base point considered the origin? I think so...

How do I define the AXIS using an XYZ? Does anyone have an image to explain this? I couldn't find any documentation. I want to rotate the point along the XY plane (in plan orientation).

The angle is in Radians, I got that one.

 

Transform transf = Transform.CreateRotationAtPoint(new XYZ(Origin.X,Origin.Y,Origin.Z +1), Math.Pi, Origin);

 

transf.whatMethodHereToGetNewXYZLocationOfPoint?

 

Once I get the transform, how do I get the new XYZ location of my rotated point?

 

thanks.

0 Likes
Accepted solutions (1)
3,068 Views
2 Replies
Replies (2)
Message 2 of 3

jeremytammik
Autodesk
Autodesk

Dear Redsky,

 

Transform.CreateRotation

creates a rotation transformation given just two arguments, the rotation axis and angle.

 

CreateRotationAtPoint takes three arguments: the axis, rotation angle and base point.

 

Here is one short description of how not to use CreateRotationAtPoint  🙂

 

http://thebuildingcoder.typepad.com/blog/2014/02/different-revit-api-aspects-and-features.html#5.2

 

To define an axis by an XYZ, simply cnsider the XYZ a vector instead of a point.

 

In your case, to determine the rotation of the point pOld to the result pNew by 180 degrees around the base point base_point in the XY plane, i.e., around the Z axis, you can do this:

 

  XYZ axis = XYZ.BasisZ;
  double angle = Math.PI;
  Transform t = Transform.CreateRotationAtPoint(
    axis, angle, base_point );
  XYZ pNew = t.OfPoint( pOld );

 

Cheers,

 

Jeremy



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

Message 3 of 3

jeremytammik
Autodesk
Autodesk
Accepted solution

Added it to The Building Coder:

 

http://thebuildingcoder.typepad.com/blog/2015/06/create-duct-pipe-and-point-transform.html#3

 

Cheers,

 

Jeremy



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder