Title: | Computations on Conics |
---|---|
Description: | Solve some conic related problems (intersection of conics with lines and conics, arc length of an ellipse, polar lines, etc.). |
Authors: | Emanuel Huber [aut, cre] |
Maintainer: | Emanuel Huber <[email protected]> |
License: | GPL (>= 2) |
Version: | 1.1.1 |
Built: | 2025-02-17 22:22:44 UTC |
Source: | https://github.com/emanuelhuber/rconics |
A package to solve some conic related problems (intersection of conics with lines and conics, arc length of an ellipse, polar lines, etc.).
Some of the functions are based on the projective geometry.
In projective geometry parallel lines meet at an infinite point and
all infinite points are incident to a line at infinity.
Points and lines of a projective plane are represented by homogeneous
coordinates, that means by 3D vectors: for the points and
such that
for the lines.
The Euclidian points correspond to
,
the infinite points to
, the Euclidean lines to
with
or
, the line at
infinity to
.
Advice: to plot conics use the package conics
from Bernard Desgraupes.
This work was funded by the Swiss National Science Foundation within the ENSEMBLE project (grant no. CRSI_132249).
Maintainer: Emanuel Huber [email protected] (ORCID)
Richter-Gebert, Jürgen (2011). Perspectives on Projective Geometry - A Guided Tour Through Real and Complex Geometry, Springer, Berlin, ISBN: 978-3-642-17285-4
Useful links:
Report bugs at https://github.com/emanuelhuber/RConics/issues
Add a homogeneous line to a plot. The line parameters must be in homogeneous coordinates, e.g. .
addLine(l, ...) plotHLine(l, ...)
addLine(l, ...) plotHLine(l, ...)
l |
A |
... |
graphical parameters such as |
# two points in homogeneous coordinates p1 <- c(3,1,1) p2 <- c(0,2,1) # homogeneous line joining p1 and p2 l_12 <- join(p1,p2) l_12 # plot plot(0,0,type="n", xlim=c(-2,5),ylim=c(-2,5),asp=1) points(t(p1)) points(t(p2)) addLine(l_12,col="red",lwd=2)
# two points in homogeneous coordinates p1 <- c(3,1,1) p2 <- c(0,2,1) # homogeneous line joining p1 and p2 l_12 <- join(p1,p2) l_12 # plot plot(0,0,type="n", xlim=c(-2,5),ylim=c(-2,5),asp=1) points(t(p1)) points(t(p2)) addLine(l_12,col="red",lwd=2)
Compute the classical adjoint (also called adjugate) of a square matrix. The adjoint is the transpose of the cofactor matrix.
adjoint(A)
adjoint(A)
A |
a square matrix. |
The adjoint matrix of A (square matrix with the same dimension as A).
A <- matrix(c(1,4,5,3,7,2,2,8,3),nrow=3,ncol=3) A B <- adjoint(A) B
A <- matrix(c(1,4,5,3,7,2,2,8,3),nrow=3,ncol=3) A B <- adjoint(A) B
This function computes the arc length of an ellipse centered in
with the semi-axes aligned with the
- and
-axes.
The arc length is defined by the points
and
.
These two points do not need to lie exactly on the ellipse:
the
-coordinate of the points and the quadrant where they lie
define the positions on the ellipse used to compute the arc length.
arcLengthEllipse(p1, p2 = NULL, saxes, n = 5)
arcLengthEllipse(p1, p2 = NULL, saxes, n = 5)
p1 |
a |
p2 |
a |
saxes |
a |
n |
the number of iterations used in the numerical approximation of the incomplete elliptic integral of the second kind. |
If the coordinates p2
of the point are omitted the function
arcLengthEllipse
computes the arc length between the point
and the point defined by
,
beeing the minor semi-axis.
The length of the shortest arc of the ellipse defined by the points 1 and 2.
Van de Vel, H. (1969). On the series expansion method for Computing incomplete elliptic integrals of the first and second kinds, Math. Comp. 23, 61-69.
p1 <- c(3,1) p2 <- c(0,2) # Ellipse with semi-axes: a = 5, b= 2 saxes <- c(5,2) # 1 iteration arcLengthEllipse(p1,p2,saxes,n=1) # 5 iterations arcLengthEllipse(p1,p2,saxes,n=5) # 10 iterations arcLengthEllipse(p1,p2,saxes,n=10)
p1 <- c(3,1) p2 <- c(0,2) # Ellipse with semi-axes: a = 5, b= 2 saxes <- c(5,2) # 1 iteration arcLengthEllipse(p1,p2,saxes,n=1) # 5 iterations arcLengthEllipse(p1,p2,saxes,n=5) # 10 iterations arcLengthEllipse(p1,p2,saxes,n=10)
-cofactor and
-minor of a matrixCompute the -cofactor, respectively the
-minor of
the matrix
. The
-cofactor is obtained by multiplying
the
-minor by
. The
-minor of
,
is the determinant of the
matrix that results
by deleting the
-th row and the
-th column of
.
cofactor(A, i, j) minor(A, i, j)
cofactor(A, i, j) minor(A, i, j)
A |
a square matrix. |
i |
the |
j |
the |
The -minor/cofactor of the matrix
(single value).
A <- matrix(c(1,4,5,3,7,2,2,8,3),nrow=3,ncol=3) A minor(A,2,3) cofactor(A,2,3)
A <- matrix(c(1,4,5,3,7,2,2,8,3),nrow=3,ncol=3) A minor(A,2,3) cofactor(A,2,3)
Tests if three points are colinear. The coordinates of the points have to be in homogeneous coordinates.
colinear(p1, p2, p3)
colinear(p1, p2, p3)
p1 |
|
p2 |
|
p3 |
|
TRUE
if the three points are colinear, else FALSE
.
Richter-Gebert, Jürgen (2011). Perspectives on Projective Geometry - A Guided Tour Through Real and Complex Geometry, Springer, Berlin, ISBN: 978-3-642-17285-4
# points: homogeneous coordinates p1 <- c(3,1,1) p2 <- c(0,2,1) p3 <- c(1.5,-2,1) p4 <- c(1,3,1) # homogeneous line passing through p1 and p2 l1 <- join(p1,p2) # homogeneous line passing through p3 and p3 l2 <- join(p3,p4) # homogeneous points formed by the intersection of the lines p5 <- meet(l1,l2) # test for colinearity colinear(p1, p2, p3) colinear(p1, p2, p5) colinear(p3, p4, p5) # plot plot(rbind(p1,p2,p3,p4),xlim=c(-5,5),ylim=c(-5,5),asp=1) abline(h=0,v=0,col="grey",lty=3) addLine(l1,col="red") addLine(l2,col="blue") points(t(p5),cex=1.5,pch=20,col="blue")
# points: homogeneous coordinates p1 <- c(3,1,1) p2 <- c(0,2,1) p3 <- c(1.5,-2,1) p4 <- c(1,3,1) # homogeneous line passing through p1 and p2 l1 <- join(p1,p2) # homogeneous line passing through p3 and p3 l2 <- join(p3,p4) # homogeneous points formed by the intersection of the lines p5 <- meet(l1,l2) # test for colinearity colinear(p1, p2, p3) colinear(p1, p2, p5) colinear(p3, p4, p5) # plot plot(rbind(p1,p2,p3,p4),xlim=c(-5,5),ylim=c(-5,5),asp=1) abline(h=0,v=0,col="grey",lty=3) addLine(l1,col="red") addLine(l2,col="blue") points(t(p5),cex=1.5,pch=20,col="blue")
Ellipses can be represented by a matrix
, such that for each point
on the ellipse
. The function
conicMatrixToEllipse
transforms the matrix into the ellipse parameters: center location, semi-axes length and angle of rotation.
conicMatrixToEllipse(A)
conicMatrixToEllipse(A)
A |
a |
loc |
a |
saxes |
a |
theta |
the angle of rotation of the ellipse (in radians). |
Wolfram, Mathworld (http://mathworld.wolfram.com/).
# ellipse parameter saxes <- c(5,2) loc <- c(0,0) theta <- pi/4 # matrix representation of the ellipse C <- ellipseToConicMatrix(saxes,loc,theta) C # back to the ellipse parameters conicMatrixToEllipse(C)
# ellipse parameter saxes <- c(5,2) loc <- c(0,0) theta <- pi/4 # matrix representation of the ellipse C <- ellipseToConicMatrix(saxes,loc,theta) C # back to the ellipse parameters conicMatrixToEllipse(C)
Return the matrix representation of the conic that passes through exactly 5 points.
conicThrough5Points(p1, p2, p3, p4, p5)
conicThrough5Points(p1, p2, p3, p4, p5)
p1 |
|
p2 |
|
p3 |
|
p4 |
|
p5 |
|
A matrix representation of the conic passing through the 5 points.
Richter-Gebert, Jürgen (2011). Perspectives on Projective Geometry - A Guided Tour Through Real and Complex Geometry, Springer, Berlin, ISBN: 978-3-642-17285-4
# five points p1 <- c(-4.13, 6.24, 1) p2 <- c(-8.36, 1.17, 1) p3 <- c(-2.03, -4.61, 1) p4 <- c(9.70, -3.49, 1) p5 <- c(8.02, 3.34, 1) # matrix representation of the conic passing # through the five points C5 <- conicThrough5Points(p1,p2,p3,p4,p5) # plot plot(rbind(p1,p2,p3,p4,p5),xlim=c(-10,10), ylim=c(-10,10), asp=1) # from matrix to ellipse parameters E5 <- conicMatrixToEllipse(C5) lines(ellipse(E5$saxes, E5$loc, E5$theta, n=500))
# five points p1 <- c(-4.13, 6.24, 1) p2 <- c(-8.36, 1.17, 1) p3 <- c(-2.03, -4.61, 1) p4 <- c(9.70, -3.49, 1) p5 <- c(8.02, 3.34, 1) # matrix representation of the conic passing # through the five points C5 <- conicThrough5Points(p1,p2,p3,p4,p5) # plot plot(rbind(p1,p2,p3,p4,p5),xlim=c(-10,10), ylim=c(-10,10), asp=1) # from matrix to ellipse parameters E5 <- conicMatrixToEllipse(C5) lines(ellipse(E5$saxes, E5$loc, E5$theta, n=500))
Return the roots of a cubic equation of the form .
cubic(p)
cubic(p)
p |
a |
A vector corresponding to the roots of the cubic equation.
W. H. Press, S.A. Teukolsky, W.T. Vetterling, B.P. Flannery (2007). NUMERICAL RECIPES - the art of scientific computing. Cambridge, University Press, chap 5.6, p. 227-229.
# cubic equation x^3 - 6x^2 + 11x - 6 = 0 # parameter b <- c(1,-6, 11, -6) # roots x0 <- cubic(b) # plot x <- seq(0,4, by=0.001) y <- b[1]*x^3 + b[2]*x^2 + b[3]*x + b[4] # plot plot(x,y,type="l") abline(h=0,v=0) points(cbind(x0,c(0,0,0)), pch=20,col="red",cex=1.8)
# cubic equation x^3 - 6x^2 + 11x - 6 = 0 # parameter b <- c(1,-6, 11, -6) # roots x0 <- cubic(b) # plot x <- seq(0,4, by=0.001) y <- b[1]*x^3 + b[2]*x^2 + b[3]*x + b[4] # plot plot(x,y,type="l") abline(h=0,v=0) points(cbind(x0,c(0,0,0)), pch=20,col="red",cex=1.8)
Return ellipse points. Usefull for ploting ellipses.
ellipse( saxes = c(1, 1), loc = c(0, 0), theta = 0, n = 201, method = c("default", "angle", "distance") )
ellipse( saxes = c(1, 1), loc = c(0, 0), theta = 0, n = 201, method = c("default", "angle", "distance") )
saxes |
a |
loc |
a |
theta |
the angle of rotation of the elllipse (in radians). |
n |
the number of points returned by the function. |
method |
The method used to return the points: either |
"default"
returns points according to the polar equation;
"angle"
returns points radially equidistant;
"distance"
returns points that are equidistant on the ellipse arc.
A matrix whose columns correspond to the Cartesian coordinates of the points lying on the ellipse.
# Ellipse parameters saxes <- c(5,2) loc <- c(0,0) theta <- pi/4 # Plot plot(ellipse(saxes, loc, theta, n=500),type="l") points(ellipse(saxes, loc, theta, n=30),pch=20,col="red") points(ellipse(saxes, loc, theta, n=30, method="angle"),pch=20,col="blue") points(ellipse(saxes, loc, theta, n=30, method="distance"),pch=20,col="green")
# Ellipse parameters saxes <- c(5,2) loc <- c(0,0) theta <- pi/4 # Plot plot(ellipse(saxes, loc, theta, n=500),type="l") points(ellipse(saxes, loc, theta, n=30),pch=20,col="red") points(ellipse(saxes, loc, theta, n=30, method="angle"),pch=20,col="blue") points(ellipse(saxes, loc, theta, n=30, method="distance"),pch=20,col="green")
Transformation of the ellipse parameters (Cartesian coordinates of the
ellipse center, length of the semi-axes and angle of rotation) into the
into the matrix representation of conics.
ellipseToConicMatrix(saxes = c(1, 1), loc = c(0, 0), theta = 0)
ellipseToConicMatrix(saxes = c(1, 1), loc = c(0, 0), theta = 0)
saxes |
a |
loc |
a |
theta |
the angle of rotation of the ellipse (in radians). |
A matrix that represents the ellipse.
# Ellipse parameters saxes <- c(5,2) loc <- c(0,0) theta <- pi/4 # Matrix representation of the ellipse C <- ellipseToConicMatrix(saxes,loc,theta)
# Ellipse parameters saxes <- c(5,2) loc <- c(0,0) theta <- pi/4 # Matrix representation of the ellipse C <- ellipseToConicMatrix(saxes,loc,theta)
Returns the point(s) of intersection between two conics in homogeneous coordinates.
intersectConicConic(C1, C2)
intersectConicConic(C1, C2)
C1 |
|
C2 |
|
The homogeneous coordinates of the intersection points.
If there are points of intersection, it returns a
matrix whose columns correspond to the homogeneous coordinates of the intersection points.
If there is only one point, a
vector of the homogeneous
coordinates of the intersection point is returned.
If there is no intersection,
NULL
is returned.
Richter-Gebert, Jürgen (2011). Perspectives on Projective Geometry - A Guided Tour Through Real and Complex Geometry, Springer, Berlin, ISBN: 978-3-642-17285-4
# Ellipse with semi-axes a=8, b=2, centered in (0,0), with orientation angle = -pi/3 C1 <- ellipseToConicMatrix(c(8,2), c(0,0), -pi/3) # Ellipse with semi-axes a=5, b=2, centered in (1,-2), with orientation angle = pi/5 C2 <- ellipseToConicMatrix(c(5,2), c(1,-2), pi/5) # intersection conic C with conic C2 p_CC2 <- intersectConicConic(C1,C2) # plot plot(ellipse(c(8,2), c(0,0), -pi/3),type="l",asp=1) lines(ellipse(c(5,2), c(1,-2), pi/5), col="blue") points(t(p_CC2), pch=20,col="blue")
# Ellipse with semi-axes a=8, b=2, centered in (0,0), with orientation angle = -pi/3 C1 <- ellipseToConicMatrix(c(8,2), c(0,0), -pi/3) # Ellipse with semi-axes a=5, b=2, centered in (1,-2), with orientation angle = pi/5 C2 <- ellipseToConicMatrix(c(5,2), c(1,-2), pi/5) # intersection conic C with conic C2 p_CC2 <- intersectConicConic(C1,C2) # plot plot(ellipse(c(8,2), c(0,0), -pi/3),type="l",asp=1) lines(ellipse(c(5,2), c(1,-2), pi/5), col="blue") points(t(p_CC2), pch=20,col="blue")
Returns the point(s) of intersection between a conic and a line in homogeneous coordinates.
intersectConicLine(C, l)
intersectConicLine(C, l)
C |
|
l |
a |
The homogeneous coordinates of the intersection points.
If there are two points of intersection, it returns a
matrix whose columns correspond to the homogeneous coordinates of the
intersection points. If there is only one point, a
vector of the homogeneous coordinates of the intersection point is returned.
If there is no intersection,
NULL
is returned.
Richter-Gebert, Jürgen (2011). Perspectives on Projective Geometry - A Guided Tour Through Real and Complex Geometry, Springer, Berlin, ISBN: 978-3-642-17285-4
#' # Ellipse with semi-axes a=8, b=2, centered in (0,0), with orientation angle = -pi/3 C <- ellipseToConicMatrix(c(8,2),c(0,0),-pi/3) # line l <- c(0.25,0.85,-3) # intersection conic C with line l: p_Cl <- intersectConicLine(C,l) # plot plot(ellipse(c(8,2),c(0,0),-pi/3),type="l",asp=1) addLine(l,col="red") points(t(p_Cl), pch=20,col="red")
#' # Ellipse with semi-axes a=8, b=2, centered in (0,0), with orientation angle = -pi/3 C <- ellipseToConicMatrix(c(8,2),c(0,0),-pi/3) # line l <- c(0.25,0.85,-3) # intersection conic C with line l: p_Cl <- intersectConicLine(C,l) # plot plot(ellipse(c(8,2),c(0,0),-pi/3),type="l",asp=1) addLine(l,col="red") points(t(p_Cl), pch=20,col="red")
The join operation of two points is the cross-product of these two points
and represents the line passing through them. The meet operation of two lines
is the cross-product of these two lines and represents their intersection.
The line parallel to a line and passing through the point
corresponds to the join of
with the meet of
and the line
at infinity.
join(p, q) meet(l, m) parallel(p, l)
join(p, q) meet(l, m) parallel(p, l)
p |
|
q |
|
l |
|
m |
|
A vector of either the homogeneous coordinates of
the meet of two lines (a point), the homogeneous representation of the
join of two points (line), or the homogeneous representation of the
parallel line. The vector has the form
.
Richter-Gebert, Jürgen (2011). Perspectives on Projective Geometry - A Guided Tour Through Real and Complex Geometry, Springer, Berlin, ISBN: 978-3-642-17285-4
p <- c(3,1,1) q <- c(0,2,1) l <- c(0.75,0.25,1) # m is the line passin through p and q m <- join(p,q) # intersection point of m and l ml <- meet(l,m) # line parallel to l and through p lp <- parallel(p,l) # plot plot(rbind(p,q),xlim=c(-5,5),ylim=c(-5,5)) abline(h=0,v=0,col="grey",lty=3) addLine(l,col="red") addLine(m,col="blue") points(t(ml),cex=1.5,pch=20,col="blue") addLine(lp,col="green")
p <- c(3,1,1) q <- c(0,2,1) l <- c(0.75,0.25,1) # m is the line passin through p and q m <- join(p,q) # intersection point of m and l ml <- meet(l,m) # line parallel to l and through p lp <- parallel(p,l) # plot plot(rbind(p,q),xlim=c(-5,5),ylim=c(-5,5)) abline(h=0,v=0,col="grey",lty=3) addLine(l,col="red") addLine(m,col="blue") points(t(ml),cex=1.5,pch=20,col="blue") addLine(lp,col="green")
Partial elliptic integral
pEllipticInt(x, saxes, n = 5)
pEllipticInt(x, saxes, n = 5)
x |
the |
saxes |
a |
n |
the number of iterations. |
Return the partial elliptic integral.
Van de Vel, H. (1969). On the series expansion method for Computing incomplete elliptic integrals of the first and second kinds, Math. Comp. 23, 61-69.
# Ellipse with semi-axes: a = 5, b= 2 saxes <- c(5,2) # 1 iteration pEllipticInt(3,saxes,n=1) # 5 iterations pEllipticInt(3,saxes,n=5) # 10 iterations pEllipticInt(3,saxes,n=10)
# Ellipse with semi-axes: a = 5, b= 2 saxes <- c(5,2) # 1 iteration pEllipticInt(3,saxes,n=1) # 5 iterations pEllipticInt(3,saxes,n=5) # 10 iterations pEllipticInt(3,saxes,n=10)
Return the polar line of a point
with respect to a conic with matrix representation
. The polar line
is defined by
.
polar(p, C)
polar(p, C)
p |
a |
C |
a |
The polar line of a point on a conic is tangent to the conic on
.
A vector of the homogeneous representation of the polar line.
Richter-Gebert, Jürgen (2011). Perspectives on Projective Geometry - A Guided Tour Through Real and Complex Geometry, Springer, Berlin, ISBN: 978-3-642-17285-4
# Ellipse with semi-axes a=5, b=2, centered in (1,-2), with orientation angle = pi/5 C <- ellipseToConicMatrix(c(5,2),c(1,-2),pi/5) # line l <- c(0.25,0.85,-1) # intersection conic C with line l: p_Cl <- intersectConicLine(C,l) # if p is on the conic, the polar line is tangent to the conic l_p <- polar(p_Cl[,1],C) # point outside the conic p1 <- c(5,-3,1) l_p1 <- polar(p1,C) # point inside the conic p2 <- c(-1,-4,1) l_p2 <- polar(p2,C) # plot plot(ellipse(c(5,2),c(1,-2),pi/5),type="l",asp=1, ylim=c(-10,2)) # addLine(l,col="red") points(t(p_Cl[,1]), pch=20,col="red") addLine(l_p,col="red") points(t(p1), pch=20,col="blue") addLine(l_p1,col="blue") points(t(p2), pch=20,col="green") addLine(l_p2,col="green") # DUAL CONICS saxes <- c(5,2) theta <- pi/7 E <- ellipse(saxes,theta=theta, n=50) C <- ellipseToConicMatrix(saxes,c(0,0),theta) plot(E,type="n",xlab="x", ylab="y", asp=1) points(E,pch=20) E <- rbind(t(E),rep(1,nrow(E))) All_tangant <- polar(E,C) apply(All_tangant, 2, addLine, col="blue")
# Ellipse with semi-axes a=5, b=2, centered in (1,-2), with orientation angle = pi/5 C <- ellipseToConicMatrix(c(5,2),c(1,-2),pi/5) # line l <- c(0.25,0.85,-1) # intersection conic C with line l: p_Cl <- intersectConicLine(C,l) # if p is on the conic, the polar line is tangent to the conic l_p <- polar(p_Cl[,1],C) # point outside the conic p1 <- c(5,-3,1) l_p1 <- polar(p1,C) # point inside the conic p2 <- c(-1,-4,1) l_p2 <- polar(p2,C) # plot plot(ellipse(c(5,2),c(1,-2),pi/5),type="l",asp=1, ylim=c(-10,2)) # addLine(l,col="red") points(t(p_Cl[,1]), pch=20,col="red") addLine(l_p,col="red") points(t(p1), pch=20,col="blue") addLine(l_p1,col="blue") points(t(p2), pch=20,col="green") addLine(l_p2,col="green") # DUAL CONICS saxes <- c(5,2) theta <- pi/7 E <- ellipse(saxes,theta=theta, n=50) C <- ellipseToConicMatrix(saxes,c(0,0),theta) plot(E,type="n",xlab="x", ylab="y", asp=1) points(E,pch=20) E <- rbind(t(E),rep(1,nrow(E))) All_tangant <- polar(E,C) apply(All_tangant, 2, addLine, col="blue")
Transformation of the quadratic conic representation into the matrix representation.
quadraticFormToMatrix(v)
quadraticFormToMatrix(v)
v |
a |
A matrix representation of the conic (symmetric matrix).
v <- c(2,2,-2,-20,20,10) quadraticFormToMatrix(v)
v <- c(2,2,-2,-20,20,10) quadraticFormToMatrix(v)
affine planar transformation matrix corresponding
to reflection, rotation, scaling and translation in projective geometry.
To transform a point
multiply the transformation matrix
with
the homogeneous coordinates
of
(e.g.
).
rotation(theta, pt = NULL) translation(v) scaling(s) reflection(alpha)
rotation(theta, pt = NULL) translation(v) scaling(s) reflection(alpha)
theta |
the angle of the rotation (in radian). |
pt |
the homogeneous coordinates of the rotation center (optional). |
v |
the |
s |
the |
alpha |
the angle made by the line of reflection (in radian). |
A affine transformation matrix.
Richter-Gebert, Jürgen (2011). Perspectives on Projective Geometry - A Guided Tour Through Real and Complex Geometry, Springer, Berlin, ISBN: 978-3-642-17285-4
p1 <- c(2,5,1) # homogeneous coordinate # rotation r_p1 <- rotation(4.5) %*% p1 # rotation centered in (3,1) rt_p1 <- rotation(4.5, pt=c(3,1,1)) %*% p1 # translation t_p1 <- translation(c(2,-4)) %*% p1 # scaling s_p1 <- scaling(c(-3,1)) %*% p1 # plot plot(t(p1),xlab="x",ylab="y", xlim=c(-5,5),ylim=c(-5,5),asp=1) abline(v=0,h=0, col="grey",lty=1) abline(v=3,h=1, col="grey",lty=3) points(3,1,pch=4) points(t(r_p1),col="red",pch=20) points(t(rt_p1),col="blue",pch=20) points(t(t_p1),col="green",pch=20) points(t(s_p1),col="black",pch=20)
p1 <- c(2,5,1) # homogeneous coordinate # rotation r_p1 <- rotation(4.5) %*% p1 # rotation centered in (3,1) rt_p1 <- rotation(4.5, pt=c(3,1,1)) %*% p1 # translation t_p1 <- translation(c(2,-4)) %*% p1 # scaling s_p1 <- scaling(c(-3,1)) %*% p1 # plot plot(t(p1),xlab="x",ylab="y", xlim=c(-5,5),ylim=c(-5,5),asp=1) abline(v=0,h=0, col="grey",lty=1) abline(v=3,h=1, col="grey",lty=3) points(3,1,pch=4) points(t(r_p1),col="red",pch=20) points(t(rt_p1),col="blue",pch=20) points(t(t_p1),col="green",pch=20) points(t(s_p1),col="black",pch=20)
skew symmetric matrixReturn a skew symmetric matrix from three parameters
.
skewSymmetricMatrix(p)
skewSymmetricMatrix(p)
p |
a |
A skew symmetric matrix, with :
Richter-Gebert, Jürgen (2011). Perspectives on Projective Geometry - A Guided Tour Through Real and Complex Geometry, Springer, Berlin, ISBN: 978-3-642-17285-4
p <- c(3,7,11) skewSymmetricMatrix(p)
p <- c(3,7,11) skewSymmetricMatrix(p)
Split a degenerate conic into two lines.
splitDegenerateConic(C)
splitDegenerateConic(C)
C |
a |
A matrix whose columns correspond to the homongeneous representation of two lines (real or complex).
Richter-Gebert, Jürgen (2011). Perspectives on Projective Geometry - A Guided Tour Through Real and Complex Geometry, Springer, Berlin, ISBN: 978-3-642-17285-4
# tw0 lines g <- c(0.75,0.25,3) h <- c(0.5,-0.25,2) # a degenerate conic D <- g %*% t(h) + h %*% t(g) # split the degenerate conic into 2 lines L <- splitDegenerateConic(D) # plot plot(0,0,xlim=c(-10,5),ylim=c(-10,10),type="n") addLine(L[,1],col="red") addLine(L[,2],col="green")
# tw0 lines g <- c(0.75,0.25,3) h <- c(0.5,-0.25,2) # a degenerate conic D <- g %*% t(h) + h %*% t(g) # split the degenerate conic into 2 lines L <- splitDegenerateConic(D) # plot plot(0,0,xlim=c(-10,5),ylim=c(-10,10),type="n") addLine(L[,1],col="red") addLine(L[,2],col="green")