rot.axis: Rotates a 2D dataset about an axis, perpendicular to the...

View source: R/rot.axis.R

rot.axisR Documentation

Rotates a 2D dataset about an axis, perpendicular to the screen

Description

Returns a dataframe after rotating an X-Y dataset abot an axis(perpendicular to the screen) passing through a point, mentioned in the function argument.

Usage

rot.axis(df, pt, deg)
rot.axis(df, deg)

Arguments

df

The X-Y dataframe that needs to be rotated.
Should be a 2 column dataframe.
The first columns hsould be the X-axis.

pt

A two element numeric vector which denotes the point around which the dataset needs to be rotated.
Default set to the ORIGIN.

deg

Angle in degrees denoting the amnount by which the dataset needs to be rotated.

Value

The returned value is always a 2 column dataframe

Author(s)

Chitran Ghosal

Examples

library(StatsChitran)

#build a linear dataset

X <- seq(-1, 1, by = 0.01)
Y <- X
dat <- data.frame(X, Y)


#plot the linear dataset

plot(dat$X, dat$Y, type = 'l')


#rotate the linear dataset

df <- rot.axis(df = dat, pt = c(0.5, 0.5), deg = 30)


#plot the rotated dataset

lines(df$X, df$Y, col = 'red')

#legend

legend("topleft", legend = c("original", "rotated"),col = c("black", "red"), lty = 1, lwd = 2)


Chitran1987/StatsChitran documentation built on Feb. 23, 2025, 8:30 p.m.