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