Use constants
This commit is contained in:
parent
76826b74e2
commit
485a25c029
|
|
@ -8,6 +8,9 @@ use crate::boundary::Loop;
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
use approx::assert_abs_diff_eq;
|
use approx::assert_abs_diff_eq;
|
||||||
|
|
||||||
|
const RAYS_IN_FAN: usize = 101;
|
||||||
|
const DT: f32 = 0.1;
|
||||||
|
|
||||||
pub fn main() {
|
pub fn main() {
|
||||||
let space = Coil {
|
let space = Coil {
|
||||||
scale: 3.0,
|
scale: 3.0,
|
||||||
|
|
@ -86,7 +89,7 @@ impl SpaceVisual for Inside {
|
||||||
impl Rayable for [Box<dyn SpacePart>] {
|
impl Rayable for [Box<dyn SpacePart>] {
|
||||||
fn draw_ray(&self, gc: &mut Vec<Draw>, base: Vec2, dir: Vec2) {
|
fn draw_ray(&self, gc: &mut Vec<Draw>, base: Vec2, dir: Vec2) {
|
||||||
gc.new_path();
|
gc.new_path();
|
||||||
let dt = 1.0;
|
let dt = DT;
|
||||||
let mut s = boundary::Id(0);
|
let mut s = boundary::Id(0);
|
||||||
let mut p = base;
|
let mut p = base;
|
||||||
let mut v = dir.normalize();
|
let mut v = dir.normalize();
|
||||||
|
|
@ -125,7 +128,7 @@ trait Rayable {
|
||||||
fn draw_fan(&self, gc: &mut Vec<Draw>, base: Vec2, dir: Vec2, spread: f32) {
|
fn draw_fan(&self, gc: &mut Vec<Draw>, base: Vec2, dir: Vec2, spread: f32) {
|
||||||
let dir = dir.normalize();
|
let dir = dir.normalize();
|
||||||
let v = vec2(-dir.y, dir.x);
|
let v = vec2(-dir.y, dir.x);
|
||||||
for y in itertools_num::linspace(-spread, spread, 101) {
|
for y in itertools_num::linspace(-spread, spread, RAYS_IN_FAN) {
|
||||||
self.draw_ray(gc, base, dir + y * v);
|
self.draw_ray(gc, base, dir + y * v);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -136,7 +139,7 @@ impl<T: Metric> Rayable for T {
|
||||||
let dir = self.globalize(base, dir);
|
let dir = self.globalize(base, dir);
|
||||||
gc.new_path();
|
gc.new_path();
|
||||||
gc.move_to(base.x, base.y);
|
gc.move_to(base.x, base.y);
|
||||||
for pt in trace_iter(self, base, dir, 1.0).take(10000) {
|
for pt in trace_iter(self, base, dir, DT).take(10000) {
|
||||||
gc.line_to(pt.x, pt.y);
|
gc.line_to(pt.x, pt.y);
|
||||||
if pt.abs().cmpgt(Vec2::splat(1000.0)).any() {
|
if pt.abs().cmpgt(Vec2::splat(1000.0)).any() {
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user