vectorgraphics / asymptote

2D & 3D TeX-Aware Vector Graphics Language
https://asymptote.sourceforge.io/
GNU General Public License v3.0
555 stars 92 forks source link

intersectionpoints line and parabola error? #271

Closed quanhinh9 closed 2 years ago

quanhinh9 commented 3 years ago

Hi,

I use intersectionpoints function of parabola and line but get error.

My code in http://asymptote.ualberta.ca:

import geometry;
import graph;
unitsize (1cm);

point A = (-4, 3), B =(4, 2), C=(-4, -2), D = (2, 2), F = (0, 3); 
parabola pa = parabola(F, line(A, B)); draw(pa);
draw(line(A, B));
line l = line (C, D); draw(l, Cyan);
point [] pv = intersectionpoints(pa, parallel(pa.V, l));
dot(Label("$pv_1$", align = SE), pv[1]);

point pv[1] does not exist?

KevinDCarlson commented 2 years ago

It looks like your line does not intersect your parabola.

johncbowman commented 2 years ago

workspace I don't know the geometry package very well, but you first want to draw a line segment, not an infinite line(A,B). An indeed, when you do this, you see that KevinArlin is correct: the black curves do not intersect:

import geometry;
import graph;
unitsize (1cm);

point A = (-4, 3), B =(4, 2), C=(-4, -2), D = (2, 2), F = (0, 3); 
line L=line(A,false,B,false);
parabola pa = parabola(F, L); draw(pa);
draw(L);
line l = line (C, D); draw(l, Cyan);
point [] pv = intersectionpoints(pa, parallel(pa.V, l));