| Crates.io | vector_2d_3d |
| lib.rs | vector_2d_3d |
| version | 0.5.1 |
| created_at | 2025-06-02 09:37:31.454617+00 |
| updated_at | 2025-08-28 18:52:18.751895+00 |
| description | Simple small library for 2D and 3D vectors |
| homepage | |
| repository | |
| max_upload_size | |
| id | 1697809 |
| size | 18,540 |
#[derive(Debug, Copy, Clone, Deserialize, Serialize)]
pub struct Vector2D {
pub x: f32,
pub y: f32,
}
new - creates a vector from the x and y coordinatefrom_coord - creates a vector from the x and y coordinatefrom_coords - creates a vector from the two x and y coordinatesfrom_mag_theta - creates a vector from the given magnitude and degrees (in radians) from the x-axisihat - creates the unit vector of the x-axisjhat - creates the unit vector of the y-axisperpendicular_cw - returns a vector that is perpendicular clockwise to the current vectorperpendicular_ccw - returns a vector that is perpendicular counter clockwise to the current vectormagnitude - returns the magnitude of the current vectordirection_as_unit_vector - returns a unit vector with the same direction of the current vectordirection - returns the degrees (theta) between the vector and the x-axisdot_product - returns the dot product of the current vector and otherdot_product_with_angle - returns the dot product of the current vector and other using their magintudes and the angle between themcross_product - programmers implementation of the cross product between 2D vectors, since it doesn't existVector2D implements the Add<f32>, Sub<f32>, Mul<f32>, Div<f32> traits.
#[derive(Debug, Copy, Clone, Deserialize, Serialize)]
pub struct Vector3D {
pub x: f32,
pub y: f32,
pub z: f32,
}
new - creates a vector from the x, y and z coordinatefrom_coord - creates a vector from the x, y and z coordinatefrom_mag_alpha_beta_gamma - creates a vector from the magnitude and angles between the x, y and z-axesfrom_mag_asimuthal_polar - creates a vector from the magnitude and angle azimuthal and polarihat - creates the unit vector of the x-axisjhat - creates the unit vector of the y-axiskhat - creates the unit vector of the z-axisperpendicular - returns a vector that is perpendicular to the current vectormagnitude - returns the magnitude of the current vectordirection_as_unit_vector - returns a unit vector with the same direction as the current vectordirection_from_axes - returns the angles between the different axesdirection - returns the direction of the current vectordot_product - returns the dot product of the current vector and othercross_product - returns the cross product of the current vector and otherVector3D implements the Add<f32>, Sub<f32>, Mul<f32>, Div<f32> traits.