# How to draw a parabola in JME

I want to draw a 3D parabola in my application, I got 3 points (3 vectors) vector3f position
I want draw a parabola from these 3 points, But I cannot find a good way to do this.
Does java or JME provide some simple ways to do this task?
I really need your help, thanks…

One idea I have used before is having a base Node object that I can rotate so that either x or z components point to a direction I want. Then I use a parabola 2D function in local space since one of the vector components is going to be constant (0 preferably) and I can either use the local coordinates of the base Node object or transform the vector to world space.

For drawing you can make a line mesh using the points you calculated.

Thanks, do you have the code example ?
In fact, my problem is that I want to draw an arc line (parabola or maybe a circle is also OK) over an 3D model earth to represent the route of airline.
I have the position of two airports on the earth, and I want to draw a parabola or an arc line between the two airports.

Here’s a rough example:

private int numOfPoints = 20;
private float parabolaHeight = 10f;

public void drawParabola(Node pointA, Node pointB){
//this makes the z axis to look at where pointB is
pointA.lookAt(pointB.getWorldTranslation(), Vector3f.UNIT_Y);

Vector3f[] parabolaPoints = new Vector3f[numOfPoints + 1];

float distance = pointA.getWorldTranslation().distance(pointB.getWorldTranslation());

//Create a parabola instance that will create an equation based on three values
//startPoint, endPoint, and height. For simplicity we better start at 0 and end
//at the distance between points
Parabola2D parabola = new Parabola2D(0f, distance, parabolaHeight);

//calculate the distance of each step or segment of the parabola along z axis
float stepDistance = distance / numOfPoints;

// calculate the points of the parabola
for(int i = 0; i <= numOfPoints; i++){
float zValue = stepDistance * i;
parabolaPoints[i] = new Vector3f(0f, parabola.getParablePoint(zValue), zValue);
}

//Now we will have a method that will create a line mesh based on the
//calculated parabola points;
Spatial parabolaLine = createParabolaLine(parabolaPoints);
pointA.attachChild(parabolaLine);
}

Parabola2D will just need three values, start point in z that will be (0, 0), the end point in z that is like (distance, 0) and the height that will be the vertex point(distance * 0.5f, height). From there you can build the equation.

1 Like

Thanks.