Search code examples
rplot3dcurve

3D plot in R and find self-intersection


What is the easiest way in Rstudio to plot the 3D parametrization

g(t)=(cos(t)^2-0.5,sin(t)*cos(t),sin(t))

After I want to find values t1 and t2, for which g(t1)=g(t2) (hence I want to find self intersection)

Also how can i make a 2D of this parametrization

g(t)=((1+2*cos(t))*cos(t),(1+2*cos(t))*sin(t))

Regards,

s


Solution

  • Here is a solution for your 3D parametrization problem:

    t <- seq(0, 2*pi, length.out=200)
    gt <- data.frame(x=cos(t)^2-0.5, y=sin(t)*cos(t), z=sin(t))
    
    library(plotly)
    plot_ly(x=~x, y=~y, z=~z, data=gt, type="scatter3d", mode="lines")
    

    enter image description here

    For your 2D parametrization:

    t <- seq(0, 2*pi, length.out=200)
    gt <- data.frame(x=(1+2*cos(t))*cos(t),y=(1+2*cos(t))*sin(t))
    
    plot(gt$x, gt$y, type="l", asp=1, xlab="x", ylab="y")
    

    enter image description here