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

View source: R/rotaxis.r

rotaxis3dR Documentation

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 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)

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.

Details

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

Value

returns rotated object (including updated normals for mesh3d objects)

Author(s)

Stefan Schlager

References

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

See Also

rotonto, rotmesh.onto

Examples


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)

Morpho documentation built on June 22, 2024, 7:19 p.m.