length of Line2D - Java 2D Graphics

Java examples for 2D Graphics:Line

Description

length of Line2D

Demo Code


//package com.java2s;

import java.awt.geom.*;

public class Main {
    private static double length(Line2D segment) {
        double x = segment.getX1() - segment.getX2();
        double y = segment.getY1() - segment.getY2();
        return Math.sqrt(x * x + y * y);
    }/*ww  w  . ja v a  2  s.  co m*/
}

Related Tutorials