org.critterai.nmgen
Class Geometry

java.lang.Object
  extended by org.critterai.nmgen.Geometry

public final class Geometry
extends Object

Provides shared computational geometry operations.

This is a temporary class. Its functionality will eventually be merged into classes in the utility library.


Method Summary
static float getPointSegmentDistanceSq(float px, float py, float pz, float ax, float ay, float az, float bx, float by, float bz)
           
static float getPointSegmentDistanceSq(int px, int py, int ax, int ay, int bx, int by)
          Returns the distance squared from the point to the line segment.
static boolean segmentsIntersect(int ax, int ay, int bx, int by, int cx, int cy, int dx, int dy)
          Returns TRUE if line segment AB intersects with line segment CD in any manner.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getPointSegmentDistanceSq

public static float getPointSegmentDistanceSq(int px,
                                              int py,
                                              int ax,
                                              int ay,
                                              int bx,
                                              int by)
Returns the distance squared from the point to the line segment.

Behavior is undefined if the the closest distance is outside the line segment.

Parameters:
px - The x-value of point (px, py).
py - The y-value of point (px, py)
ax - The x-value of the line segment's vertex A.
ay - The y-value of the line segment's vertex A.
bx - The x-value of the line segment's vertex B.
by - The y-value of the line segment's vertex B.
Returns:
The distance squared from the point (px, py) to line segment AB.

getPointSegmentDistanceSq

public static float getPointSegmentDistanceSq(float px,
                                              float py,
                                              float pz,
                                              float ax,
                                              float ay,
                                              float az,
                                              float bx,
                                              float by,
                                              float bz)

segmentsIntersect

public static boolean segmentsIntersect(int ax,
                                        int ay,
                                        int bx,
                                        int by,
                                        int cx,
                                        int cy,
                                        int dx,
                                        int dy)
Returns TRUE if line segment AB intersects with line segment CD in any manner. Either collinear or at a single point.

Parameters:
ax - The x-value for point (ax, ay) in line segment AB.
ay - The y-value for point (ax, ay) in line segment AB.
bx - The x-value for point (bx, by) in line segment AB.
by - The y-value for point (bx, by) in line segment AB.
cx - The x-value for point (cx, cy) in line segment CD.
cy - The y-value for point (cx, cy) in line segment CD.
dx - The x-value for point (dx, dy) in line segment CD.
dy - The y-value for point (dx, dy) in line segment CD.
Returns:
TRUE if line segment AB intersects with line segment CD in any manner.


Project Home and Source Code

Copyright 2010 Stephen Pratt. All rights reserved. Use is subject to license terms.