Solved

# Curves and x, y points

Posted on 2002-06-24

Hello everybody,

What I want is straightforward.

I need all the X, Y pairs of points of a quadratic curve.

For example I know the x1, y1 & x2, y2 and finally ctrX1 & ctrY1 points

to make the quadratic curve.

But I need to know the x,y points that this line is made of so I wil be able to

make an animation of an image up to this path. I itend not to draw the actual

line.

I found the PathIterator in the API but this does not really solve my problem.

From my understanding it reconstructs a complex shape with the aid of simpler ones.

It doesn't give any clues about the x,y points.

If I am wrong please tell me.

I found also a piece of code that I change it a bit to fit my needs. This will be

the worst solution though.

I cannot believe that for that simple problem I need to do the following. There must

be a simpler way.

What I found is to:

1. Make the curve

2. Take the Rectangle for that Shape with getBounds()

3. Make a smaller curve line

4. Take the rectangle for this as well

5. Subtract the areas (Not know how to do this)

6. Find the x, y points for the final area

Actually what I have just said is not the worst solution.

I thought somwthing even worst than this. :)

Anyway

I am not sure if this is possible.

What I have on hands is that foloowing code.

QuadCurve2D.Double q2d2 = new QuadCurve2D.Double( 10, 200, 95, 50, 200, 200);

r1 = q2d.getBounds2D().getBounds();

for (int x=0; x < r1.width; x++)

{

for (int y=0; y < r1.height; y++)

{

if (ar1.intersects(r1.x+x,r1.y+y,1,1)) // this point is on the arc

{

g2d.fillRect(r1.x + x, r1.y + y, 1, 1);

}

}

}

I do not know how to take the Area though form the previous shape.

Anybody can help me with some sample solution ???

Any comments ??

Other simpler ways ?

Do you thing I am in the right trck ?

Thank you in advance.