Here you can find the source of relTo(final Point2D from, final Point2D to, final Point2D rel)
Parameter | Description |
---|---|
from | The starting point of the vector. |
to | The vector the orientation is calculated for. |
rel | The vector relative to the other. |
public static final int relTo(final Point2D from, final Point2D to, final Point2D rel)
//package com.java2s; //License from project: Open Source License import java.awt.geom.Point2D; public class Main { /**//from ww w. j a va 2 s . com * Calculates the relative orientation of two vectors. * * @param from * The starting point of the vector. * @param to * The vector the orientation is calculated for. * @param rel * The vector relative to the other. * @return {@code > 0} if {@code rel} is left of {@code from -> to} and * {@code < 0} if {@code rel} is right of {@code from -> to}. */ public static final int relTo(final Point2D from, final Point2D to, final Point2D rel) { return (int) Math.signum((to.getX() - from.getX()) * (from.getY() - rel.getY()) - (rel.getX() - from.getX()) * (from.getY() - to.getY())); } }