geo_conic_section_from_5points: Conic section from five point

View source: R/geometry.R

geo_conic_section_from_5pointsR Documentation

Conic section from five point

Description

calculate conic section from five given points section_points

Usage

geo_conic_section_from_5points(section_points, nb = 10)

Arguments

section_points

matrix of section points, one point per row.

nb

number of points returned to plot the ellipse

Details

Ax^2+Bxy+Cy^2+Dx+Ey+F=0

https://en.wikipedia.org/wiki/Conic_section

The algorithm determines fist the type of conic section. If the conic section results in an ellipse or a circle the function returns useful values such as the equation and the centre of the ellipse or circle. Additionally you can define the number of points returned nb to visualize the ellipse or the circle. For an ellipse additionally the semi b and major axis a of the ellipse are provided.

Value

list, check out the example.

Author(s)

Florian Wagner florian.wagner@wagnius.ch

Examples

section_points <- matrix(c(-1,3,
                          2,4,
                          6,2,
                          8,-5,
                          1,-3),
                          nrow = 5, byrow = TRUE)
l_list <- geo_conic_section_from_5points(section_points, nb = 20)
l_list
l_list$df|>plot(asp = 1)
abline(a = l_list$lf_a_b[1,2], b = l_list$lf_a_b[1,1])
abline(a = l_list$lf_a_b[2,2], b = l_list$lf_a_b[2,1])
points(x = l_list$center[1],y = l_list$center[2])

# hyperbola
matrix(c(-2,1,
         -1,3,
         1,-1.5,
         0.8,0.8,
         2,2.8),
         nrow = 5, byrow = TRUE)|>
   geo_conic_section_from_5points()

#circle
l_list <- (matrix(c(-1,0,
         0,1,
         1,0,
         0,-1,
         cos(pi/4),sin(pi/4)),
         nrow = 5, byrow = TRUE)+0.2)|>
   geo_conic_section_from_5points(nb = 20)
l_list
l_list$df|>plot(asp=1)

#parabola
matrix(c(-2,3,
         -1,0,
         0,-1,
         1,0,
         2,3),
         nrow = 5, byrow = TRUE)|>
   geo_conic_section_from_5points()

wagnius-GmbH/slvwagner documentation built on Jan. 19, 2025, 7:10 a.m.