Java Geometry Algorithm AreAlign(Point2D.Double pivot, Point2D.Double a, Point2D.Double b)

Here you can find the source of AreAlign(Point2D.Double pivot, Point2D.Double a, Point2D.Double b)

Description

Are Align

License

BSD License

Declaration

public static boolean AreAlign(Point2D.Double pivot, Point2D.Double a, Point2D.Double b) 

Method Source Code

//package com.java2s;
/**************************************************************************************************
 **************************************************************************************************
     // w  w  w .  j a va 2  s  .  c om
 BSD 3-Clause License (https://www.tldrlegal.com/l/bsd3)
     
 Copyright (c) 2010 Andr?s Sol?s Montero <http://www.solism.ca>, All rights reserved.
     
     
 Redistribution and use in source and binary forms, with or without modification,
 are permitted provided that the following conditions are met:
     
 1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
 2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
 3. Neither the name of the copyright holder nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
     
 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
 OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
 OF THE POSSIBILITY OF SUCH DAMAGE.
     
 **************************************************************************************************
 **************************************************************************************************/

import java.awt.geom.Point2D;

public class Main {
    public static boolean AreAlign(Point2D.Double pivot, Point2D.Double a, Point2D.Double b) {
        return (TriangleArea(pivot, a, b) == 0);
    }

    public static double TriangleArea(Point2D.Double pivot, Point2D.Double a, Point2D.Double b) {
        double area = 0;
        double D = ((a.x - pivot.x) * (b.y - pivot.y)) - ((a.y - pivot.y) * (b.x - pivot.x));
        area = D / 2.0;

        return area;

    }
}

Related

  1. applyCoG(Point2D.Double[] points, Point2D.Double cog)
  2. applyDynamism(final Point[] spline, final int msForMove, final int msPerMove)
  3. applyMidPointApprox(CubicCurve2D cubic, QuadCurve2D quad)
  4. arcThroughThreePoints(float x1, float y1, float x2, float y2, float x3, float y3, boolean clockwise)
  5. area2(Point2D a, Point2D b, Point2D c)
  6. areDifferentAnchorPoints(Point2D p1, Point2D p2)
  7. areLocationsClose(Point2D point1, Point2D point2)
  8. assertEDT(String point)
  9. botCorners(Point2D.Double p)