Move multiplication out of flat-global vector conversion
The conversion is necessarily linear so...
This commit is contained in:
parent
2b7ae9485b
commit
f3288c7331
|
|
@ -68,13 +68,13 @@ pub fn main() {
|
|||
gc.stroke_color(Color::Rgba(0.0, 0.0, 0.0, 0.5));
|
||||
draw_loop(gc, itertools_num::linspace(0.0, 2.0 * PI, 32).skip(1).map(|φ| {
|
||||
let dir = Vec2::from_angle(φ) * obj.r;
|
||||
let dir = space.flat_to_global(pos, dir);
|
||||
let dir = space.flat_to_global(pos) * dir;
|
||||
pos + dir
|
||||
}));
|
||||
gc.stroke_color(Color::Rgba(0.0, 0.5, 1.0, 0.5));
|
||||
draw_loop(gc, itertools_num::linspace(0.0, 2.0 * PI, 32).skip(1).map(|φ| {
|
||||
let dir = Vec2::from_angle(φ) * obj.r;
|
||||
let dir = space.flat_to_global(pos, dir);
|
||||
let dir = space.flat_to_global(pos) * dir;
|
||||
space.trace_step(Ray { pos, dir }).pos
|
||||
}));
|
||||
gc.stroke_color(Color::Rgba(0.5, 0.0, 1.0, 1.0));
|
||||
|
|
@ -82,7 +82,7 @@ pub fn main() {
|
|||
let n = obj.r.floor();
|
||||
let d = obj.r / n;
|
||||
let dir = Vec2::from_angle(φ);
|
||||
let dir = space.flat_to_global(pos, dir) * d;
|
||||
let dir = space.flat_to_global(pos) * dir * d;
|
||||
space.trace_iter(Ray { pos, dir }).nth(n as usize).unwrap().pos
|
||||
}));
|
||||
}
|
||||
|
|
@ -134,12 +134,12 @@ impl Space {
|
|||
}
|
||||
}
|
||||
|
||||
fn flat_to_global(&self, at: Vec2, v: Vec2) -> Vec2 {
|
||||
Mat2::from(self.rect.sqrt_at(at).inverse()) * v
|
||||
fn flat_to_global(&self, at: Vec2) -> Mat2 {
|
||||
Mat2::from(self.rect.sqrt_at(at).inverse())
|
||||
}
|
||||
|
||||
fn global_to_flat(&self, at: Vec2, v: Vec2) -> Vec2 {
|
||||
Mat2::from(self.rect.sqrt_at(at)) * v
|
||||
fn global_to_flat(&self, at: Vec2) -> Mat2 {
|
||||
Mat2::from(self.rect.sqrt_at(at))
|
||||
}
|
||||
|
||||
/// Выполняет один шаг трассировки. Работает в любой части пространства, но вне Boundary доступны более эффективные методы.
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user