Package net.algart.math.geometry
Class Collinearity
java.lang.Object
net.algart.math.geometry.Collinearity
Functions for checking collinearity of vectors.
- Author:
- Daniel Alievsky
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic boolean
alsoCodirectional
(long x1, long y1, long z1, long x2, long y2, long z2) Returns true if two collinear 3D vectors (x1,y1,z1) and (x2,y2,z2) are also co-directional.static boolean
collinear
(int x1, int y1, int z1, int x2, int y2, int z2) Returns true if and only if two collinear 3D vectors (x1,y1,z1) and (x2,y2,z2) are collinear.static boolean
collinear
(long x1, long y1, long z1, long x2, long y2, long z2) Returns true if and only if two collinear 3D vectors (x1,y1,z1) and (x2,y2,z2) are collinear.static boolean
collinear
(long x1, long y1, long z1, long x2, long y2, long z2, MutableInt128 temp1, MutableInt128 temp2) Returns true if and only if two collinear 3D vectors (x1,y1,z1) and (x2,y2,z2) are collinear.
-
Constructor Details
-
Collinearity
public Collinearity()
-
-
Method Details
-
collinear
public static boolean collinear(int x1, int y1, int z1, int x2, int y2, int z2) Returns true if and only if two collinear 3D vectors (x1,y1,z1) and (x2,y2,z2) are collinear.This method is the equivalent of
collinear(long, long, long, long, long, long)
method, optimized for the case of 32-bit int arguments.- Parameters:
x1
- x-component of the first vector.y1
- y-component of the first vector.z1
- z-component of the first vector.x2
- x-component of the second vector.y2
- y-component of the second vector.z2
- z-component of the second vector.- Returns:
- whether two vectors are collinear.
-
collinear
public static boolean collinear(long x1, long y1, long z1, long x2, long y2, long z2) Returns true if and only if two collinear 3D vectors (x1,y1,z1) and (x2,y2,z2) are collinear.Note that this method allocates two temporary
MutableInt128
objects. If you need to call it more than once, you can optimize this by allocating these two objects in your code and reusing them many times with help of the methodcollinear(long, long, long, long, long, long, MutableInt128, MutableInt128)
.- Parameters:
x1
- x-component of the first vector.y1
- y-component of the first vector.z1
- z-component of the first vector.x2
- x-component of the second vector.y2
- y-component of the second vector.z2
- z-component of the second vector.- Returns:
- whether two vectors are collinear.
-
collinear
public static boolean collinear(long x1, long y1, long z1, long x2, long y2, long z2, MutableInt128 temp1, MutableInt128 temp2) Returns true if and only if two collinear 3D vectors (x1,y1,z1) and (x2,y2,z2) are collinear.Unlike
collinear(long, long, long, long, long, long)
, this method requires to pass two non-null objectsMutableInt128
: it will use them as working memory. Thus, this method does not allocate new objects and is faster.- Parameters:
x1
- x-component of the first vector.y1
- y-component of the first vector.z1
- z-component of the first vector.x2
- x-component of the second vector.y2
- y-component of the second vector.z2
- z-component of the second vector.temp1
- some non-null temporary instance ofMutableInt128
.temp2
- some other non-null temporary instance ofMutableInt128
.- Returns:
- whether two vectors are collinear.
- Throws:
NullPointerException
- if temp1 or temp2 is null.
-
alsoCodirectional
public static boolean alsoCodirectional(long x1, long y1, long z1, long x2, long y2, long z2) Returns true if two collinear 3D vectors (x1,y1,z1) and (x2,y2,z2) are also co-directional. Note that the result has no sense for non-collinear vectors: you should check this fact separately, for example, usingcollinear(long, long, long, long, long, long)
method.- Parameters:
x1
- x-component of the first vector.y1
- y-component of the first vector.z1
- z-component of the first vector.x2
- x-component of the second vector, collinear to the first.y2
- y-component of the second vector, collinear to the first.z2
- z-component of the second vector, collinear to the first.- Returns:
- whether two vectors are co-directional.
-