Revit API Forum
Welcome to Autodesk’s Revit API Forums. Share your knowledge, ask questions, and explore popular Revit API topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Rotate a XYZ Point Around Base Point

1 REPLY 1
Reply
Message 1 of 2
sam.zielkeryner
3661 Views, 1 Reply

Rotate a XYZ Point Around Base Point

Hello

I am attempting to rotate a XYZ point around the base point. I have some code that attempts to do this but its producing the incorrect result.

How do you rotate a XYZ point around the base point?

As a test, my project's base point is (100, 100, 0) with an angle to true north of 60 degrees. I attempt to rotate the XYZ point (110, 110, 0) around this base point by 60 degrees. The result should be (113.66, 96.33, 0) but my code produces (73.4, 246.6, 0).

Any ideas what I am doing wrong?

// Obtain Base Point Position
XYZ             origin          = new XYZ(0, 0, 0);
ProjectLocation projectLocation = doc.ActiveProjectLocation;
ProjectPosition position        = projectLocation.get_ProjectPosition(origin);

// Rotate the point (110,110,0) around the base point (100,100,0) where the angle is 60 degrees
Transform rot 		= Transform.CreateRotationAtPoint(XYZ.BasisZ, position.Angle, new XYZ(position.EastWest, position.NorthSouth, position.Elevation));
Transform pos 		= Transform.get_Translation( new XYZ(110, 110, 0) );
Transform rotPos 	= pos.Multiply(rot);

// Correct rotation should be (113.66,96.33,0) but the result gives (73.4,246.6,0)
TaskDialog.Show("Result: ", string.Format("{0}, {1}, {2}", rotPos.Origin.X, rotPos.Origin.Y, rotPos.Origin.Z));

 

 



1 REPLY 1
Message 2 of 2
Lucavox
in reply to: sam.zielkeryner

 

Hello.

 

I have done some corrections to your code. 

 

 

The code for the rotation is:

double angle_degree = 60;

double angle_internal_revit_units = 60 * Math.PI/180 *( -1);

 

 

Transform rot         = Transform.CreateRotationAtPoint(XYZ.BasisZ, angle_internal_revit_units, new XYZ(100,100,0));


XYZ transformed = rot.OfPoint(new XYZ(110,110,0));

// You will have  (113.66,96.33,0)


TaskDialog.Show("Result: "string.Format("{0}, {1}, {2}", transformed.X, transformed.Y, transformed.Z));

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Rail Community