File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes Calculate length of line. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Calculate length of line." Watch "Calculate length of line." New topic

Calculate length of line.

Jan L

Joined: Apr 30, 2001
Posts: 3
Does someone now how i can calculate the length of a line between
the points (X1, Y1) and (X2, Y2) on an applet?

Art Metzer
Ranch Hand

Joined: Oct 31, 2000
Posts: 241

In other words, take the square of the difference of your x's plus the square of the difference of the y's, and the length will be the positive square root of that sum. At heart, it's the Pythagorean theorem.
Good luck,
Frank Carver

Joined: Jan 07, 1999
Posts: 6920
"Jan L",
The Java Ranch has thousands of visitors every week, many with surprisingly similar names. To avoid confusion we have a naming convention, described at .
We require names to have at least two words, separated by a space, and strongly recommend that you use your full real name. Please log in again with a new name which meets the requirements.

Read about me at ~ Raspberry Alpha Omega ~ Frank's Punchbarrel Blog
I agree. Here's the link:
subject: Calculate length of line.
It's not a secret anymore!