2 releases
0.1.2 | Jul 13, 2023 |
---|---|
0.1.1 | Jul 13, 2023 |
0.1.0 |
|
#593 in Graphics APIs
41KB
802 lines
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
:vectorlib
is ready to be deployed.
-
2023-07-12 22:53
:- Now the implementation work for both
.add()
method and theoperators
for all the given operations (addition, subtractions, multiplication, division)
- Now the implementation work for both
-
2023-07-12 23:22
:- Finished adding the
verboseVectors
which 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
Engine
crate for our animation platform.
- Create the struct for the
Notes
-
2023-07-12 22:24
:- For the
verboseVectors
I have used the composition of and built on top of the vector2d. This was necessary since I cannot add a nother field calledverbose
for the struct ofVector2d
(standAdd
,Sub
,Div
andMul
needs only two fields). - For implementing the
std::fmt::Display
for theverboseVectors
, I found a creative way to extract first theSome(vector)
sinceOption
is not implementing for theDisplay
trait, check thestd::fmt::Display
trait at the end of theverbose_vector2d_module.rs
module.
- For the
-
2023-07-10 22:49:26
:- Up to this point the
Vector2d
supports- (+,-,*,/) operators for the vector
- Input can be vector or scalar
.add()
,.div()
,.mul()
and.sub()
accepts onlyVector2d
cannot 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
vectorResult
for example. - Support traits for display in debugging mode.
- Operators overloading for (+)/(-)/(/)/(*) for our vector.
- Adding support for other vector methods - in progress
-
lerp
function. -
distance
between two vectors. -
cross
product similar to the dot product. -
negate
-
zero
vector initalizer. -
ones
vector initalizer.
-
Welcome message
- You can run the command, for lunching the
src/main.rs
which is not necessary, but I created for demostration purposes.
cargo run --quiet
# or
cargo run -j 10 --quiet
Testing Module
- Using the testing command below will run the
test/tests.rs
script along side with the documentation scripts for each metho in thevectorlib::math::vector_module::Vector2d
ofVector2d
strcut methods.
cargo test
- 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--nocapture
flag. This flag prevents the test framework from capturing the output, allowing the printed values to be displayed in the console.
cargo test -- --nocapture
# Or
cargo test -j 8 -- --nocapture
Dependencies
~0.4–10MB
~51K SLoC