# What do ptLineDist and relativeCCW do? [closed]

I saw these methods in the Line2D Java Docs but did not understand what they do?

Javadoc for `ptLineDist` says:

Returns the distance from a point to this line. The distance measured is the distance between the specified point and the closest point on the infinitely-extended line defined by this `Line2D`. If the specified point intersects the line, this method returns 0.0

Doc for `relativeCCW` says:

Returns an indicator of where the specified point (PX, PY) lies with respect to the line segment from (X1, Y1) to (X2, Y2). The return value can be either 1, -1, or 0 and indicates in which direction the specified line must pivot around its first endpoint, (X1, Y1), in order to point at the specified point (PX, PY).

A return value of 1 indicates that the line segment must turn in the direction that takes the positive X axis towards the negative Y axis. In the default coordinate system used by Java 2D, this direction is counterclockwise.

A return value of -1 indicates that the line segment must turn in the direction that takes the positive X axis towards the positive Y axis. In the default coordinate system, this direction is clockwise.

A return value of 0 indicates that the point lies exactly on the line segment. Note that an indicator value of 0 is rare and not useful for determining colinearity because of floating point rounding issues.

If the point is colinear with the line segment, but not between the endpoints, then the value will be -1 if the point lies "beyond (X1, Y1)" or 1 if the point lies "beyond (X2, Y2)".

• put references where did you see that. Sep 22, 2012 at 2:50
• if you are the one who -1'd me, I already wrote JAVA DOCS. If not, I apologize :p Sep 22, 2012 at 2:54
• if my reference is correct, it is a name of class not a method Sep 22, 2012 at 3:03
• Did you click on the methods and read the (slightly more) detailed docs? Sep 22, 2012 at 3:07
• Yes, I did @AnnaLear Sep 22, 2012 at 18:45

`ptLineDist` is the shortest distance between a point and a line.
`relativeCCW` tells you which direction a line would have to rotate in order to direct itself at a point. (I really wanted to say "point at a point" there).