What mathematical formula can I use to rotate a series of 3d Vectors about a given 3d Vector?
I am attempting to use the 3rd party library: Math.NET Iridium to calculate my rotations but I dont know what formulas or mathematical concepts I should use. As you can see Maths is not my strong point thus the need for the library.
PS: I've attempted to use the standard System.Windows.Shapes.Polyline
and System.Windows.Media.RotateTransform
but it looks like the rotation is only applied at rendering time (correct me if I am wrong). I need to know the location of the rotated point right after I apply the RotateTransform
.
public static XYZ rotateXYZ(XYZ pnt)
{
Polyline polyline = new Polyline();
polyline.Points.Add(new Point(pnt.X, pnt.Y)); //, pnt.Z));
System.Windows.Media.RotateTransform rotateTransform = new System.Windows.Media.RotateTransform(projectRotation, pnt.X, pnt.Y);
polyline.RenderTransform = rotateTransform;
return new XYZ(polyline.Points[0].X, polyline.Points[0].Y, pnt.Z); // the points coordinates are the same - not rotated
}
See Rotation Matrix for the mathematical background/formula, section "Rotation matrix from axis and angle".
If you'd like to use a library: Math.NET Iridium (and its successor Math.NET Numerics) are numerical methods libraries, but you could use Math.NET Spatial instead.
Note that Math.NET Spatial is in a very early phase, so there is no release or NuGet package yet. But you can compile it yourself, or simply have a look at the code to see how it was implemented.