Whether point a must be rotated clockwise around the center point to align with point b. - Java java.lang

Java examples for java.lang:Math Geometry

Description

Whether point a must be rotated clockwise 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 2s  .  co m
     * Whether point a must be rotated clockwise around the center point to align
     * with point b.
     * 
     * @param center The center of rotation.
     * @param a Point a.
     * @param b Point b.
     * @return Whether the rotation must be clockwise.
     */
    public static boolean isClockwiseOf(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