Learn R Programming

Morpho (version 2.12)

rotaxis3d: Rotate an object (matrix or mesh) around an arbitrary axis in 3D

Description

Rotate an object around an arbitrary axis in 3D

Usage

rotaxis3d(x, pt1, pt2 = c(0, 0, 0), theta)

# S3 method for matrix rotaxis3d(x, pt1, pt2 = c(0, 0, 0), theta)

# S3 method for mesh3d rotaxis3d(x, pt1, pt2 = c(0, 0, 0), theta)

Value

returns rotated object (including updated normals for mesh3d objects)

Arguments

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.

Author

Stefan Schlager

Details

Rotate an object (matrix or triangular mesh) around an 3D-axis defined by two points.

References

http://en.wikipedia.org/wiki/Rotation_matrix

See Also

rotonto, rotmesh.onto

Examples

Run this code

require(rgl)
data(nose)
shrot.rot <- rotaxis3d(shortnose.mesh,pt1=c(1,1,1),theta=pi)
if (FALSE) {
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)))
}

Run the code above in your browser using DataLab