JavaFX divide Line Fraction - Java JavaFX

Java examples for JavaFX:Line

Description

JavaFX divide Line Fraction

Demo Code


//package com.java2s;
import javafx.geometry.Point2D;
import javafx.geometry.Point3D;

public class Main {
    public static Point2D divideLineFraction(Point2D start, Point2D end,
            double fraction) {
        double x = start.getX() + fraction * (end.getX() - start.getX());
        double y = start.getY() + fraction * (end.getY() - start.getY());
        return new Point2D(x, y);
    }//  ww  w .ja  va2  s.c  o m

    public static Point3D divideLineFraction(Point3D start, Point3D end,
            double fraction) {
        double x = start.getX() + fraction * (end.getX() - start.getX());
        double y = start.getY() + fraction * (end.getY() - start.getY());
        double z = start.getZ() + fraction * (end.getZ() - start.getZ());
        return new Point3D(x, y, z);
    }
}

Related Tutorials