@Test public void testIsOnSegment() { assertTrue(Vector3.isPointOnSegment(new Vector3(0, 0), new Vector3(10, 10), new Vector3(5, 5))); assertFalse(Vector3.isPointOnSegment(new Vector3(0, 0), new Vector3(10, 10), new Vector3(15, 15))); assertFalse(Vector3.isPointOnSegment(new Vector3(0, 0), new Vector3(10, 10), new Vector3(-5, -5))); assertFalse(Vector3.isPointOnSegment(new Vector3(0, 0), new Vector3(10, 10), new Vector3(5, 3))); }
public static boolean isPointOnSegment(Vector3 start, Vector3 end, Vector3 point) { if ((point.x - start.x) * (end.z - start.z) == (end.x - start.x) * (point.z - start.z) && Math.min(start.x, end.x) <= point.x && point.x <= Math.max(start.x, end.x) && Math.min(start.z, end.z) <= point.z && point.z <= Math.max(start.z, end.z)) return true; else return false; }
Vector3 implements Serializable, Cloneable, Vector<Vector3> { public static boolean isPointOnSegment(Vector3 start, Vector3 end, Vector3 point) { if ((point.x - start.x) * (end.z - start.z) == (end.x - start.x) * (point.z - start.z) && Math.min(start.x, end.x) <= point.x && point.x <= Math.max(start.x, end.x) && Math.min(start.z, end.z) <= point.z && point.z <= Math.max(start.z, end.z)) return true; else return false; } }
Vector3 implements Serializable, Cloneable, Vector<Vector3> { public static boolean isPointOnSegment(Vector3 start, Vector3 end, Vector3 point) { if ((point.x - start.x) * (end.z - start.z) == (end.x - start.x) * (point.z - start.z) && Math.min(start.x, end.x) <= point.x && point.x <= Math.max(start.x, end.x) && Math.min(start.z, end.z) <= point.z && point.z <= Math.max(start.z, end.z)) return true; else return false; } Vector3();  Vector3(float degree);  Vector3(float x, float z);  Vector3(float x, float y, float z);  Vector3(Vector3 old); }
Vector3 implements Serializable, Cloneable, Vector<Vector3> { public static boolean isPointOnSegment(Vector3 start, Vector3 end, Vector3 point) { if ((point.x - start.x) * (end.z - start.z) == (end.x - start.x) * (point.z - start.z) && Math.min(start.x, end.x) <= point.x && point.x <= Math.max(start.x, end.x) && Math.min(start.z, end.z) <= point.z && point.z <= Math.max(start.z, end.z)) return true; else return false; } Vector3();  Vector3(float degree);  Vector3(float x, float z);  Vector3(float x, float y, float z);  Vector3(Vector3 old); Vector3 copy(); float getX(); void setX(float x); float getY(); void setY(float y); float getZ(); void setZ(float z); float dst2(Vector3 p); static float dst2(float x1, float z1, float x2, double z2); static float dst2(final float x1, final float y1, final float z1, final float x2, final float y2,
			final float z2); float dst2(float x, float y, float z); float dst(Vector3 p); static float dst(Vector3 vector1, Vector3 vector2); static float dst(float x1, float z1, float x2, float z2); float dst(float x, float y, float z); int relCCW(Vector3 p1, Vector3 p2); static int relCCW(float x1, float z1, float x2, float z2, float px, float py); static float relCCWDouble(float x1, float z1, float x2, float z2, float px, float py); double relCCWDouble(Vector3 p1, Vector3 p2); double ptSegDistSq(double x1, double z1, double x2, double z2); double ptSegDistSq(Vector3 start, Vector3 end); static double ptSegDistSq(double x1, double z1, double x2, double z2, double px, double py); double ptLineDistSq(Vector3 start, Vector3 end); static double ptLineDistSq(double x1, double z1, double x2, double z2, double px, double py); Vector3 unityTranslate(Vector3 sourceDirection, float degrees, float distance); Vector3 unityTranslate(float degrees, float distance); static double unityDegreesToAngle(double degrees); Vector3 translateCopy(float degrees, float radius); @Override Vector3 clone(); @Override String toString(); double distanceSqlt2D(Vector3 point); static Vector3 getClosestPointOnSegment(float x1, float z1, float x2, float z2, float px, float py); float findAngle(Vector3 dest); static float findAngle(Vector3 start, Vector3 dest); static float findAngle(float x1, float z1, float x2, float z2); static float findSignedAngle(float x1, float z1, float x2, float z2); Vector3 createPointFromAngle(float angle, float distance); static Vector3 createPointFromAngle(Vector3 source, float angle, float distance); boolean isInSector(Vector3 sourceDirection, Vector3 target, float radius, float degrees); static double angle(Vector3 v1, Vector3 v2); float dot(final Vector3 vector); static float dot(float x1, float y1, float z1, float x2, float y2, float z2); float dot(float x, float y, float z); float len(); float len2D(); static float len(final float x, final float y, final float z); Vector3 sub(final Vector3 a_vec); Vector3 sub(float x, float y, float z); static Vector3 sub(Vector3 left, Vector3 right); void addX(double x); void addY(double y); void addZ(double z); @JSONField(serialize = false) boolean isZero(); static boolean linesIntersect(Vector3 p1, Vector3 p2, Vector3 p3, Vector3 p4); static boolean linesIntersect(double x1, double z1, double x2, double z2, double x3, double y3, double x4,
			double y4); @Override Vector3 add(final Vector3 vector); Vector3 add(float x, float y, float z); Vector3 set(float x, float y, float z); @Override Vector3 set(final Vector3 vector); @Override Vector3 scl(float scalar); @Override Vector3 scl(final Vector3 other); Vector3 cross(final Vector3 vector); Vector3 cross(float x, float y, float z); @Override Vector3 nor(); void nor2D(); @Override float len2(); static float cross2D(Vector3 fromPoint, Vector3 toPoint, Vector3 p); static boolean pointInLineLeft(Vector3 fromPoint, Vector3 toPoint, Vector3 p); Vector3 mul(final Matrix4 matrix); @Override boolean equal(Vector3 vector3, float precision); boolean equal(Vector3 vector3); void clear(); static float toUnityDegrees(Vector3 start, Vector3 end); static float toUnityDegrees(float angle); @Override Vector3 mulAdd(Vector3 vec, float scalar); static Vector3 dirVector(Vector3 from, Vector3 to); boolean isColoseTo(Vector3 vector3, float maxDistance); @Override int hashCode(); @Override boolean equals(Object obj); @Override Vector3 lerp(final Vector3 target, float alpha); static Vector3 move(float deltaTime, Vector3 currentPosition, Vector3 targetPositon, float speed); static boolean isPointOnSegment(Vector3 start, Vector3 end, Vector3 point); }
Vector3 implements Serializable, Cloneable, Vector<Vector3> { public static boolean isPointOnSegment(Vector3 start, Vector3 end, Vector3 point) { if ((point.x - start.x) * (end.z - start.z) == (end.x - start.x) * (point.z - start.z) && Math.min(start.x, end.x) <= point.x && point.x <= Math.max(start.x, end.x) && Math.min(start.z, end.z) <= point.z && point.z <= Math.max(start.z, end.z)) return true; else return false; } Vector3();  Vector3(float degree);  Vector3(float x, float z);  Vector3(float x, float y, float z);  Vector3(Vector3 old); Vector3 copy(); float getX(); void setX(float x); float getY(); void setY(float y); float getZ(); void setZ(float z); float dst2(Vector3 p); static float dst2(float x1, float z1, float x2, double z2); static float dst2(final float x1, final float y1, final float z1, final float x2, final float y2,
			final float z2); float dst2(float x, float y, float z); float dst(Vector3 p); static float dst(Vector3 vector1, Vector3 vector2); static float dst(float x1, float z1, float x2, float z2); float dst(float x, float y, float z); int relCCW(Vector3 p1, Vector3 p2); static int relCCW(float x1, float z1, float x2, float z2, float px, float py); static float relCCWDouble(float x1, float z1, float x2, float z2, float px, float py); double relCCWDouble(Vector3 p1, Vector3 p2); double ptSegDistSq(double x1, double z1, double x2, double z2); double ptSegDistSq(Vector3 start, Vector3 end); static double ptSegDistSq(double x1, double z1, double x2, double z2, double px, double py); double ptLineDistSq(Vector3 start, Vector3 end); static double ptLineDistSq(double x1, double z1, double x2, double z2, double px, double py); Vector3 unityTranslate(Vector3 sourceDirection, float degrees, float distance); Vector3 unityTranslate(float degrees, float distance); static double unityDegreesToAngle(double degrees); Vector3 translateCopy(float degrees, float radius); @Override Vector3 clone(); @Override String toString(); double distanceSqlt2D(Vector3 point); static Vector3 getClosestPointOnSegment(float x1, float z1, float x2, float z2, float px, float py); float findAngle(Vector3 dest); static float findAngle(Vector3 start, Vector3 dest); static float findAngle(float x1, float z1, float x2, float z2); static float findSignedAngle(float x1, float z1, float x2, float z2); Vector3 createPointFromAngle(float angle, float distance); static Vector3 createPointFromAngle(Vector3 source, float angle, float distance); boolean isInSector(Vector3 sourceDirection, Vector3 target, float radius, float degrees); static double angle(Vector3 v1, Vector3 v2); float dot(final Vector3 vector); static float dot(float x1, float y1, float z1, float x2, float y2, float z2); float dot(float x, float y, float z); float len(); float len2D(); static float len(final float x, final float y, final float z); Vector3 sub(final Vector3 a_vec); Vector3 sub(float x, float y, float z); static Vector3 sub(Vector3 left, Vector3 right); void addX(double x); void addY(double y); void addZ(double z); @JSONField(serialize = false) boolean isZero(); static boolean linesIntersect(Vector3 p1, Vector3 p2, Vector3 p3, Vector3 p4); static boolean linesIntersect(double x1, double z1, double x2, double z2, double x3, double y3, double x4,
			double y4); @Override Vector3 add(final Vector3 vector); Vector3 add(float x, float y, float z); Vector3 set(float x, float y, float z); @Override Vector3 set(final Vector3 vector); @Override Vector3 scl(float scalar); @Override Vector3 scl(final Vector3 other); Vector3 cross(final Vector3 vector); Vector3 cross(float x, float y, float z); @Override Vector3 nor(); void nor2D(); @Override float len2(); static float cross2D(Vector3 fromPoint, Vector3 toPoint, Vector3 p); static boolean pointInLineLeft(Vector3 fromPoint, Vector3 toPoint, Vector3 p); Vector3 mul(final Matrix4 matrix); @Override boolean equal(Vector3 vector3, float precision); boolean equal(Vector3 vector3); void clear(); static float toUnityDegrees(Vector3 start, Vector3 end); static float toUnityDegrees(float angle); @Override Vector3 mulAdd(Vector3 vec, float scalar); static Vector3 dirVector(Vector3 from, Vector3 to); boolean isColoseTo(Vector3 vector3, float maxDistance); @Override int hashCode(); @Override boolean equals(Object obj); @Override Vector3 lerp(final Vector3 target, float alpha); static Vector3 move(float deltaTime, Vector3 currentPosition, Vector3 targetPositon, float speed); static boolean isPointOnSegment(Vector3 start, Vector3 end, Vector3 point); static final float TWO_PI; static final float degreesToRadians; static final float radiansToDegrees; static final Vector3 ZERO; final static Vector3 X; final static Vector3 Y; final static Vector3 Z; volatile float x; volatile float y; volatile float z; }