Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vectors Package Update #2

Open
wants to merge 67 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
67 commits
Select commit Hold shift + click to select a range
85ebeef
Vector2D clean up
ttchalakov Jul 9, 2021
2b810f1
Added general vector 3D methods
ttchalakov Jul 9, 2021
53bb116
Added CoordinateSystem interface
ttchalakov Jul 15, 2021
e4e81bb
Added general, 2D, and 3D vector operations interface
ttchalakov Jul 15, 2021
ec10feb
Added interface for coordinate transformations
ttchalakov Jul 15, 2021
3df826a
Fixed clarity
ttchalakov Jul 15, 2021
4e2175f
Added generic vector class
ttchalakov Jul 15, 2021
a001664
Added incomplete generic 2D and 3D vector class
ttchalakov Jul 15, 2021
eb955b0
Added coordiante system skeletons to implement
ttchalakov Jul 15, 2021
e767791
Started vectors v2 with point, space, vector interface
ttchalakov Aug 10, 2021
e1aebaf
Added cartesian 2D space
ttchalakov Aug 10, 2021
3879c66
Started cartesian 2d vector
ttchalakov Aug 10, 2021
0097252
Added point operations
ttchalakov Nov 23, 2021
ef92c62
Added 2D and 3D specific operations interface
ttchalakov Nov 23, 2021
a417a2a
Removed erroring class definitions
ttchalakov Nov 23, 2021
8fc306e
Put isInfinite in point interface
ttchalakov Nov 23, 2021
e2e687a
Made cartesian2d space into singleton
ttchalakov Nov 23, 2021
a46cf7f
Added polar, spherical, cylindrical, cart3d space
ttchalakov Nov 23, 2021
8726770
Added getSpace method to point class
ttchalakov Nov 23, 2021
d9f023c
Added vector projection method
ttchalakov Nov 23, 2021
d90001c
Renamed variable a to scalar
ttchalakov Nov 23, 2021
61bc503
Implemented Vector2D in new structure
ttchalakov Nov 23, 2021
ad41c6b
Made third geometry version with previous benefits
ttchalakov Nov 23, 2021
636def0
Removed vector2D casts
ttchalakov Nov 23, 2021
99aad50
Commented out minus and plus point operations
ttchalakov Nov 23, 2021
11da4eb
Added cartesian 3D vector
ttchalakov Nov 23, 2021
3f41093
Implemented polar vector
ttchalakov Nov 24, 2021
38815fa
Removed old geometry package versions
ttchalakov Nov 24, 2021
9216569
Added equals with tolerance and azimuthal angle
ttchalakov Nov 24, 2021
d76dc57
Moved and refactored vector packages
ttchalakov Nov 24, 2021
8d2751d
Refactored vec 2d and 3d unit tests
ttchalakov Nov 24, 2021
0cb366c
Added azimuthal angle implementation to polar
ttchalakov Nov 24, 2021
4c0013c
Fixed Cartesian2D to polar conversion
ttchalakov Nov 25, 2021
d52e8e7
Added cartesian3d unit test and polar convert test
ttchalakov Nov 25, 2021
cd15f7b
Deleted old vec 2 3 D added shortest angle of vecs
ttchalakov Nov 25, 2021
6115c1a
Added unit test for shortest angle between vectors
ttchalakov Nov 25, 2021
d6fa635
Fixed polar to cartesian to return zero
ttchalakov Nov 25, 2021
1e6d1b8
Fixed cart to polar conversion floating point err
ttchalakov Nov 25, 2021
aa82043
Wrote polar vector unit tests
ttchalakov Nov 25, 2021
7ac0f1b
Added optional polar constructor
ttchalakov Nov 25, 2021
4fa731c
Added cart 3d to cylindrical conversion
ttchalakov Nov 25, 2021
5135f9d
Removed unnecessary cartesian conversion
ttchalakov Nov 25, 2021
5e11f79
Wrote cylindrical vector class
ttchalakov Nov 25, 2021
9bf5702
Documented cylindrical coordinate ranges
ttchalakov Nov 25, 2021
4806da1
Added cart3D to spherical conversion
ttchalakov Nov 25, 2021
4897fe8
Implemented spherical vectors
ttchalakov Nov 25, 2021
d548fe9
Added cylindrical to spherical conversion
ttchalakov Nov 25, 2021
31000b3
Added spherical to cylindrical conversion
ttchalakov Nov 25, 2021
a97988c
Removed AbstractPoint plus and minus methods
ttchalakov Nov 25, 2021
d138f49
Added unfinished cylindrical unit tests
ttchalakov Dec 1, 2021
4f42eaf
Added cylindrical to cart transform test
ttchalakov Dec 27, 2021
2b26f40
Removed negative r logic for all vectors
ttchalakov Dec 27, 2021
52c19f1
Fixed cart 3d to cylindrical transformation
ttchalakov Dec 27, 2021
52a88b4
Fixed sphere and polar mag squared function
ttchalakov Dec 28, 2021
0d4908a
Fixed near zero tolerance for cart to spherical
ttchalakov Dec 28, 2021
7738796
Added more conversions unit tests
ttchalakov Dec 28, 2021
66c1b9f
Added spherical unit test
ttchalakov Dec 28, 2021
ea33504
Documented AbstractPoint
ttchalakov Dec 28, 2021
4da5066
Added AbstractVectorOperations javadoc
ttchalakov Dec 28, 2021
0fc3cd9
Added CoordinateSystem javadoc
ttchalakov Dec 28, 2021
967cc46
Added Vector2D/3DOperations javadoc
ttchalakov Dec 28, 2021
8ef0b89
Added VectorCartesian2D javadoc
ttchalakov Dec 28, 2021
c42455a
Added Polar Vector javadoc
ttchalakov Dec 28, 2021
b2b870b
Added Cartesian3D javadoc
ttchalakov Dec 29, 2021
90fa0a4
Added Cylindrical vector java doc
ttchalakov Dec 29, 2021
5181118
Added spherical vector javadoc
ttchalakov Dec 29, 2021
5d6d06d
Added paul's notes resources links.
ttchalakov Dec 29, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package com.titanrobotics2022.geometry;

/**
* Represents a generic geometric point.
* @param <S> Type of the coordinate system that the point is defined by.
*/
public interface AbstractPoint<S extends CoordinateSystem> {

/**
* Checks if any of the coordinates are NaN; false otherwise.
* @return True if any of the coordinates are NaN; false otherwise.
*/
boolean isNaN();

/**
* Checks if any of the coordiantes are positive or negative infinity; false otherwise.
* @return True if any of the coordiantes are positive or negative infinity; false otherwise.
*/
boolean isInfinite();

/**
* Get the space to which the point belongs.
* @return Returns the defining space type.
*/
CoordinateSystem getSpace();

/**
* Asserts that two coordinates are equal with tolerance.
* @param rhs Coordinate to be compared to implicit coordinate.
* @param tolerance Maximum tolerance difference between coordinates.
* @return True if coordinates are within tolerance of each other; false otherwise.
*/
boolean equals(S rhs, double tolerance);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
package com.titanrobotics2022.geometry;

/**
* Represents general operations that can be performed on all geometric vectors.
* @param <S> Type of the coordinate system that the vector is defined by.
* @implNote All operations can be optimized for different vector spaces in implementing classes.
*/
public interface AbstractVectorOperations<S extends CoordinateSystem> extends AbstractPoint<S> {

/**
* Get the null vector of the vector space or origin point of the affine space.
* @return null vector of the vector space or origin point of the affine space
*/
S getZero();

/**
* Perform addition on the lhs implicit vector with the rhs explicit vector.
* <p>result = lhs + rhs
* @param rhs The vector addend.
* @return Sum of two vectors.
*/
S plus(S rhs);

/**
* Perform subtraction on the lhs implicit vector with the rhs explicit vector.
* <p>result = lhs - rhs
* @param rhs The vector subtractend.
* @return Difference of two vectors.
*/
S minus(S rhs);

/**
* Perform scalar multiplication to the implicit vector.
* <p>result = scalar * vector
* @apiNote This method should be used to divide by scaling the vector by 1 / divisor.
* User will need to check for zero division.
* @param scalar Coefficient to scale vector by.
* @return The scaled vector.
*/
S scalarMultiply(double scalar);

/**
* Same as scalar multiplication by -1 to the implicit vector.
* <p>result = -1 * vector
* @return A vector pointing in the opposite geometric direction with same magnitude.
*/
S negate();

/**
* The geometric/euclidean norm of the vector.
* @return The geometric length of the vector.
*/
double magnitude();

/**
* The geometric/euclidean norm of the vector squared.
* @implNote Should be implemented without squaring the magnitude to optimize execution.
* <p>Ex: Cartesian2D magnitude squared = x * x + y * y.
* @return The geometric length of the vector squared.
*/
double magnitudeSquared();

/**
* Computes a normalized geometric vector (magnitude 1).
* @return Normalizes a vector.
*/
S unitVector();

/**
* Computes the dot/scalar product of an implicit and explicit geometric vector.
* <p>result = lhs * rhs
* @param rhs A second vector.
* @return The dot product of lhs implicit and rhs explicit.
*/
double dot(S rhs);

/**
* The projection of implicit vector onto explicit vector.
* <p>result = proj(implicit) onto explicit
* @param targetVec Vector to project onto.
* @return The resulting projection.
*/
S projectOnto(S targetVec);

/**
* The signed angle made between the vector and the positive x-axis
* @return Angle in radians
*/
double azimuthalAngle();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.titanrobotics2022.geometry;

/**
* A generic geometric coordinate system that represents a vector space.
*/
public interface CoordinateSystem {

/**
* Gets the number of dimensions in the space.
* @return The number of dimensions in the space.
*/
int getDimension();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.titanrobotics2022.geometry;

/**
* Represents 2-Dimensional general operations that can be performed on all 2-Dimensional geometric vectors.
* @param <S> Type of the 2-Dimensional coordinate system that the vector is defined by.
* @implNote Does not check if the coordinate system contains 2 dimensions.
* @implNote All operations can be optimized for different vector spaces in implementing classes.
*/
public interface Vector2DOperations<S extends CoordinateSystem> extends AbstractVectorOperations<S> {

/**
* The cross product of two vectors.
* In two dimensions such a cross product has no z dimension which means that
* lhs and rhs vectors are coplanar so resulting cross product only contains the z dimension.
* <p>result = lhs X rhs
* @apiNote Useful for computing surface normals found in graphics computation.
* @param rhs The rhs vector of the cross product.
* @return The z component of the cross product (can be negative).
*/
public double cross(S rhs);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.titanrobotics2022.geometry;

/**
* Represents 3-Dimensional general operations that can be performed on all 3-Dimensional geometric vectors.
* @param <S> Type of the 3-Dimensional coordinate system that the vector is defined by.
* @implNote Does not check if the coordinate system contains 3 dimensions.
* @implNote All operations can be optimized for different vector spaces in implementing classes.
*/
public interface Vector3DOperations<S extends CoordinateSystem> extends AbstractVectorOperations<S> {

/**
* The cross product of two vectors.
* <p>result = lhs X rhs
* @param rhs The rhs vector of the cross product.
* @return A 3-Dimensional vector.
*/
public S cross(S rhs);
}

This file was deleted.

Loading