Velocity Reviews > Java > finding uniformly spaced points on Arc2D

finding uniformly spaced points on Arc2D

Jeff Higgins
Guest
Posts: n/a

 01-08-2007
Hi,
I would like to use java.awt.geom.Arc2D.Double
to draw an arc. I would now like to draw tic marks
onto the arc at uniformly spaced points.

Can someone explain how I might find the uniformly
spaced points on the arc?

Thanks,
Jeff Higgins

Andrew Thompson
Guest
Posts: n/a

 01-08-2007
Jeff Higgins wrote:

> Can someone explain how I might find the uniformly
> spaced points on the arc?

Do you mean points that are an equal distance apart
for an hypothetical traveller following the path, or points
that are equally distant 'as the crow flies' (in a straight
line from point A to point B)?

Note that your words imply the second, but an arc
might have any number of points that are 'uniformly
spaced' from any given point.

Andrew T.

Jeff Higgins
Guest
Posts: n/a

 01-08-2007

Andrew Thompson wrote:
> Jeff Higgins wrote:
>
>> Can someone explain how I might find the uniformly
>> spaced points on the arc?

>
> Do you mean points that are an equal distance apart
> for an hypothetical traveller following the path, or points
> that are equally distant 'as the crow flies' (in a straight
> line from point A to point B)?
>

Hi Andrew,
Sorry for being unclear. Equal distance apart, as
in the traveller. I'm attempting to draw a scale, much
like the scale of a voltmeter.

Jeff Higgins

Googmeister
Guest
Posts: n/a

 01-08-2007

Jeff Higgins wrote:
> Hi,
> I would like to use java.awt.geom.Arc2D.Double
> to draw an arc. I would now like to draw tic marks
> onto the arc at uniformly spaced points.
>
> Can someone explain how I might find the uniformly
> spaced points on the arc?

It's an arc of a circle, say of d degrees. Just divide
the arc into segments of d/n degrees to get n+1
equally spaced points (both as-the-crow-flies
and as-the-traveler-walks).

John Ersatznom
Guest
Posts: n/a

 01-08-2007
Googmeister wrote:
> Jeff Higgins wrote:
>
>>Hi,
>> I would like to use java.awt.geom.Arc2D.Double
>>to draw an arc. I would now like to draw tic marks
>>onto the arc at uniformly spaced points.
>>
>>Can someone explain how I might find the uniformly
>>spaced points on the arc?

>
> It's an arc of a circle, say of d degrees. Just divide
> the arc into segments of d/n degrees to get n+1
> equally spaced points (both as-the-crow-flies
> and as-the-traveler-walks).

Equally-spaced both ways, but not quite the same distances. For a
subtended angle of theta between successive ticks and a radius of rho
for the full circle, the traveller walks a distance of

rho*theta

while the crow flies only

rho*sqrt((cos(theta) - 1)^2 + sin(theta)^2)

Note that the latter square root is of

cos^2(theta) + sin^2(theta) - 2cos(theta) + 1

which equals

2 - 2cos(theta)

so the crow flies rho*sqrt(2 - 2cos(theta))

I leave proving sqrt(2 - 2cos(theta)) < theta as an exercise for the reader.

Daniel Pitts
Guest
Posts: n/a

 01-08-2007

Jeff Higgins wrote:
> Hi,
> I would like to use java.awt.geom.Arc2D.Double
> to draw an arc. I would now like to draw tic marks
> onto the arc at uniformly spaced points.
>
> Can someone explain how I might find the uniformly
> spaced points on the arc?
>
> Thanks,
> Jeff Higgins

One solution might be to set up your graphics2d object to use a Stroke:

<http://java.sun.com/j2se/1.4.2/docs/api/java/awt/BasicStroke.html>

graphics.setStroke(dashedStroke);