Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

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

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

Calculations and Visualisations Related to Geometric Morphometrics

v2.8
GPL-2
Authors
Stefan Schlager [aut, cre, cph], Gregory Jefferis [ctb], Dryden Ian [cph]
Initial release
2020-02-26

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.