Vector2d Library
The following library is created for handling the vector for the animation library where we put our engine.
The libray has several modules and support
Changelog
-
2023-07-13 20:32:vectorlibis ready to be deployed.
-
2023-07-12 22:53:- Now the implementation work for both
.add()method and theoperatorsfor all the given operations (addition, subtractions, multiplication, division)
- Now the implementation work for both
-
2023-07-12 23:22:- Finished adding the
verboseVectorswhich will let us know when the vector gets dropped from the memeory (useful for debugging purposes). - Implementing the test for all assocaited methods.
- Finished adding the
-
2023-07-10 21:36:30:- Create the struct for the
vectorlib - Support testing for unit test and library documentation test.
- Imported to the
Enginecrate for our animation platform.
- Create the struct for the
Notes
-
2023-07-12 22:24:- For the
verboseVectorsI have used the composition of and built on top of the vector2d. This was necessary since I cannot add a nother field calledverbosefor the struct ofVector2d(standAdd,Sub,DivandMulneeds only two fields). - For implementing the
std::fmt::Displayfor theverboseVectors, I found a creative way to extract first theSome(vector)sinceOptionis not implementing for theDisplaytrait, check thestd::fmt::Displaytrait at the end of theverbose_vector2d_module.rsmodule.
- For the
-
2023-07-10 22:49:26:- Up to this point the
Vector2dsupports- (+,-,*,/) operators for the vector
- Input can be vector or scalar
.add(),.div(),.mul()and.sub()accepts onlyVector2dcannot acceptscalar- Meaning that
let s = v.div(8.0)will not work.
- Meaning that
- (+,-,*,/) operators for the vector
- Up to this point the
Features
- Generic format for the vector
- Logging and error handling, check
vectorResultfor example. - Support traits for display in debugging mode.
- Operators overloading for (+)/(-)/(/)/(*) for our vector.
- Adding support for other vector methods - in progress
-
lerpfunction. -
distancebetween two vectors. -
crossproduct similar to the dot product. -
negate -
zerovector initalizer. -
onesvector initalizer.
-
Welcome message
- You can run the command, for lunching the
src/main.rswhich is not necessary, but I created for demostration purposes.
# or
Testing Module
- Using the testing command below will run the
test/tests.rsscript along side with the documentation scripts for each metho in thevectorlib::math::vector_module::Vector2dofVector2dstrcut methods.
- Sometimes we want to see the results output of some selected variables by the
specified
test. To see the printed values during cargo test, you can use the--nocaptureflag. This flag prevents the test framework from capturing the output, allowing the printed values to be displayed in the console.
# Or