Whether point a must be rotated counter-clockwise or in negative y direction around the center point to align with point b. - Java java.lang

Java examples for java.lang:Math Geometry Shape

Description

Whether point a must be rotated counter-clockwise or in negative y direction around the center point to align with point b.

Demo Code


//package com.java2s;

import java.awt.geom.Line2D;
import java.awt.geom.Point2D;

public class Main {
    /**/*from  w ww  .j  a v  a  2 s  . c  om*/
     * Whether point a must be rotated counter-clockwise or in negative y
     * direction around the center point to align with point b. Note that the y
     * direction is downwards.
     * 
     * @param center The center of rotation.
     * @param a Point a.
     * @param b Point b.
     * @return Whether the rotation must be counter-clockwise.
     */
    public static boolean isCounterClockwiseOf(final Point2D center,
            final Point2D a, final Point2D b) {
        return Line2D.relativeCCW(center.getX(), center.getY(), a.getX(),
                a.getY(), b.getX(), b.getY()) < 0;
    }
}

Related Tutorials