# finding uniformly spaced points on Arc2D

Discussion in 'Java' started by Jeff Higgins, Jan 8, 2007.

1. ### Jeff HigginsGuest

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

Jeff Higgins, Jan 8, 2007

2. ### Andrew ThompsonGuest

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.

Andrew Thompson, Jan 8, 2007

3. ### Jeff HigginsGuest

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.

Thanks for any help you can give me,
Jeff Higgins

Jeff Higgins, Jan 8, 2007
4. ### GoogmeisterGuest

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).

Googmeister, Jan 8, 2007
5. ### John ErsatznomGuest

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.

John Ersatznom, Jan 8, 2007
6. ### Daniel PittsGuest

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);

Daniel Pitts, Jan 8, 2007