static bool draw_traced_ray_recurs(Renderer renderer, TracedRay ray, double lost_len, Element ref_, bool hit_image, int D, bool draw_lost) { Transform3 t1 = ray.get_creator().get_transform_to(ref_); Element i_element = null; Vector3 v0 = t1.transform(ray.get_ray().origin()); Vector3 v1; if (ray.is_lost()) { if (!draw_lost) { return(false); } v1 = t1.transform(ray.get_ray().origin().plus(ray.get_ray().direction().times(lost_len))); } else { i_element = ray.get_intercept_element(); Transform3 t2 = i_element.get_transform_to(ref_); v1 = t2.transform(ray.get_intercept_point()); } Vector3Pair p = new Vector3Pair(v0, v1); bool done = false; for (TracedRay child_ray = ray.get_first_child(); child_ray != null; child_ray = child_ray.get_next_child()) { if (draw_traced_ray_recurs(renderer, child_ray, lost_len, ref_, hit_image, 2, false)) { done = true; } } if (!done && hit_image && !(i_element is Image)) { return(false); } switch (D) { case 2: // skip non tangential rays in 2d mode if (Math.Abs(p.x1()) > 1e-6) { return(false); } draw_ray_line(renderer, new Vector2Pair(p.v0.project_zy(), p.v1.project_zy()), ray); break; case 3: draw_ray_line(renderer, p, ray); break; } return(true); }
void draw_2d_e(Renderer r, Stop stop, Element ref_) { Vector3 mr = new Vector3(0, stop.get_external_radius(), 0); Vector3 top = new Vector3(0, stop.get_shape().get_outter_radius(Vector2.vector2_01), 0); Vector3 bot = new Vector3(0, -stop.get_shape().get_outter_radius(Vector2.vector2_01.negate()), 0); Transform3 t = stop.get_transform_to(ref_); Rgb color = r.get_style_color(stop.get_style()); r.group_begin(""); r.draw_segment(t.transform(top), t.transform(mr), color); r.draw_segment(t.transform(bot), t.transform(mr.negate()), color); r.group_end(); }
void get_2d_points(Surface surface, Vector2[] array, double start, double end, Element ref_) { int count = array.Length; double y1 = start; double step = (end - start) / (count - 1); int i; Transform3 t = surface.get_transform_to(ref_); for (i = 0; i < (int)count; i++) { Vector3 v = new Vector3(0.0, y1, 0.0); v = v.z(surface.get_curve().sagitta(v.project_xy())); array[i] = t.transform(v).project_zy(); y1 += step; } }
public Vector2 projection_ortho(Vector3 v) { return(_cam_transform.transform(v).project_xy()); }