1
0
mirror of https://github.com/emilk/egui.git synced 2026-08-31 13:50:04 -04:00

[emath] RectTransform: transforms Pos2 from one Rect to another

Very useful for transforming coordinate systems, e.g. for painting
This commit is contained in:
Emil Ernerfeldt
2021-02-14 10:33:44 +01:00
parent dbc6a620cd
commit c376d0bb7e
8 changed files with 142 additions and 24 deletions

View File

@@ -8,7 +8,9 @@ use super::Vec2;
// `vec2(c,s)` represents where the X axis will end up after rotation.
//
/// Represents a rotation in the 2D plane.
//
/// A rotation of 𝞃/4 = 90° rotates the X axis to the Y axis.
//
/// Normally a `Rot2` is normalized (unit-length).
/// If not, it will also scale vectors.
#[derive(Clone, Copy, PartialEq)]
@@ -104,6 +106,7 @@ impl std::ops::Mul<Rot2> for Rot2 {
}
}
/// Rotates (and maybe scales) the vector.
impl std::ops::Mul<Vec2> for Rot2 {
type Output = Vec2;
fn mul(self, v: Vec2) -> Vec2 {
@@ -114,6 +117,7 @@ impl std::ops::Mul<Vec2> for Rot2 {
}
}
/// Scales the rotor.
impl std::ops::Mul<Rot2> for f32 {
type Output = Rot2;
fn mul(self, r: Rot2) -> Rot2 {
@@ -124,6 +128,7 @@ impl std::ops::Mul<Rot2> for f32 {
}
}
/// Scales the rotor.
impl std::ops::Mul<f32> for Rot2 {
type Output = Rot2;
fn mul(self, r: f32) -> Rot2 {
@@ -134,6 +139,7 @@ impl std::ops::Mul<f32> for Rot2 {
}
}
/// Scales the rotor.
impl std::ops::Div<f32> for Rot2 {
type Output = Rot2;
fn div(self, r: f32) -> Rot2 {