View source: R/conicConverters.r
rotateA | R Documentation |
rotateA
Takes as input "parA," the 6 values of the general quadratic Ax^2 + Bxy + Cy^2 +Dx + Ey +F = 0 , and applies a rotation angle to the coefficient set.
derotateA
calculates the rotation angle required to change the conic section defined by 'parA' into one that is orthogonal to the cartesian axes.
xyrot
is a simple function to rotate the coordinate system by theta.
rotateA(parA, theta)
derotateA(parA, ACmin = 1e-05)
xyrot(x, y = NULL, theta)
parA |
the 6 values of the general quadratic Ax^2 + Bxy + Cy^2 +Dx + Ey +F = 0 |
theta |
the angle, in radians, to rotate the conic section. |
ACmin |
A tolerance parameter for deciding that the product of parameters A and C is actually zero (in which case the type of conic section is more likely a parabola or a degenerate case) |
x |
Either a vector of x-coordinates or a Nx2 array of x and y coordinates, in which case the y-input is ignored |
y |
A vector of y-coordinates. |
derotateA
uses the following standard formula to calculate the angle.
Derotate means to remove the xy term, i.e. force B = 0 . Some algebra shows that cot(2theta) = (A-C)/B and thus tan(2theta) = B/(A-C)
For xyrot
, the internal xy.coords
is used. If you enter only a vector for x and nothing for y, this will feed the new vectors 1:N for x and x-input for y to the rotator, which is probably not useful.
For derotateA
,
parA |
the new 6-parameter set defining the derotated conic. |
theta |
the derived angle by which the parameter set was rotated |
For rotateA
parA |
the new 6-parameter set defining the rotated conic. |
theta |
the angle by which the parameter set was rotated |
For xyrot
a Nx2 array of the x,y coordinates of the rotated data set.
Carl Witthoft, carl@witthoft.com
createConic
# make an ellipse and derotate it
parGr <- c(-2.3,4.2,5,3,pi/4)
xe <-seq(-8,9,by=.05)
elipGr <- createConic(xe, parGr, 'e')
plot(elipGr, t= 'l', asp = TRUE)
# convert to ABCDEF form
parAr <- GtoA(parGr,'e')
elipAr <- createConic(xe,parAr$parA)
points(elipAr,pch='.',col='red')
# remove rotation angle
parAd <- derotateA(parAr$parA)
# returns theta = pi/4, how much the ellipse had been rotated by
elipAd <-createConic(xe,parAd$parA)
lines(elipAd)
# rotate back
parAdr <- rotateA(parAd$parA, parAd$theta)
elipAdr <-createConic(xe,parAdr$parA)
lines(elipAdr,lty=3, lwd = 3, col='green')
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.