geo_slerp: slerp by 3 points and a given radius.

View source: R/geometry.R

geo_slerpR Documentation

slerp by 3 points and a given radius.

Description

Radius interpolation by 3 points and a given radius. The Radius interpolation will be calculated using the cp = common centre point and the vector x1 as the starting point and the vector x2 as the end point.

Usage

geo_slerp(R, x1, x2, cp, nb_points = 10)

Arguments

R

radius

x1

starting point vector

x2

end point vector

cp

common centre point vector

nb_points

count of points to be generate by the function.

Details

The slerp calculation is done by the following formula:

Slerp(p_0,p_1,t) = \frac{sin((1 - t) \cdot \Omega)}{sin(\Omega)} \cdot p_0 + \frac{sin(t \cdot \Omega)}{sin(\Omega)} \cdot p_1

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

Value

Matrix with nrow(nb_points)

Author(s)

Florian Wagner florian.wagner@wagnius.ch

Examples

p <- data.frame(x1 = c(-10,-5,50),
                x2 = c(-20,10,2),
                cp = c(10,-10,10))|>
   as.matrix()|>
   t()

m <- geo_slerp(R  =10,
               x1 = p["x1",],
               x2 = p["x2",],
               cp = p["cp",],
               nb_points = 20)
print(m)

#Plot 3D
library(rgl)
plot3d( m, type = "p", lwd = 2, top = TRUE,
        col = rainbow(nrow(m)),
        aspect = "iso")
plot3d(p, add = TRUE, col = "black")

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