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:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user