How to find length of QuadCurve2D

Hi,

my requirement is as follows:

- I have QuadCurve2D with start,control and endpoint. I am able to move Curve on mouseclick. Now I want to put a point on the curve with equidistance to each other(i.e. as the curve increase these points should also be moved).

Idea which came into my mind is: Find out the length of the curve and then divide it by 3 and get the location of it.

Any good approach to do so? Will appreciate if there is any code avail

thanks

chintan

[509 byte] By [chintan_34a] at [2007-11-26 14:10:55]
# 1
Put curve into flatteningpathiterator. The iterator will return all segments as line segments.
rkippena at 2007-7-8 1:58:46 > top of Java-index,Security,Cryptography...
# 2
Hi,Do you have sample code for it?RegardsChintan
chintan_34a at 2007-7-8 1:58:46 > top of Java-index,Security,Cryptography...
# 3

Here is an example:

--QuadLength.java--

import java.awt.geom.*;

public class QuadLength {

public static void main(String [] args) {

PathIterator iter =

(new QuadCurve2D.Double(0, 0, 100, 0, 100, 100)).getPathIterator(

null, 0.5);

double length = 0;

double [] curSeg = new double[2];

iter.currentSegment(curSeg);

iter.next();

double x0 = curSeg[0];

double y0 = curSeg[1];

while(!iter.isDone()) {

iter.currentSegment(curSeg);

length += Math.sqrt((curSeg[0] - x0)*(curSeg[0] - x0) +

(curSeg[1] - y0)*(curSeg[1] - y0));

x0 = curSeg[0];

y0 = curSeg[1];

iter.next();

}

System.out.println("Curve length:" + length);

}

}

AlexeyUshakova at 2007-7-8 1:58:46 > top of Java-index,Security,Cryptography...