Rotate an object (matrix or mesh) around an arbitrary axis in 3D
Rotate an object around an arbitrary axis in 3D
rotaxis3d(x, pt1, pt2 = c(0, 0, 0), theta) ## S3 method for class 'matrix' rotaxis3d(x, pt1, pt2 = c(0, 0, 0), theta) ## S3 method for class 'mesh3d' rotaxis3d(x, pt1, pt2 = c(0, 0, 0), theta)
x |
k x 3 matrix containing 3D-coordinates or a triangular mesh of class "mesh3d". |
pt1 |
numeric vector of length 3, defining first point on the rotation axis. |
pt2 |
numeric vector of length 3, defining second point on the rotation axis. |
theta |
angle to rotate in radians. With pt1 being the viewpoint, the rotation is counterclockwise. |
Rotate an object (matrix or triangular mesh) around an 3D-axis defined by two points.
returns rotated object (including updated normals for mesh3d objects)
Stefan Schlager
http://en.wikipedia.org/wiki/Rotation_matrix
require(rgl) data(nose) shrot.rot <- rotaxis3d(shortnose.mesh,pt1=c(1,1,1),theta=pi) ## Not run: shade3d(shortnose.mesh,col=3,specular=1) shade3d(shrot.rot,col=2) ###print rotation axis #' lines3d(rbind(rep(-0.1,3),rep(0.1,3))) ## End(Not run)
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.