/// <summary> /// Inspector - Draw an extruded radial arc at a particular angle of the specified arc (i.e. the extrusion is its own arc). /// </summary> /// <param name="arc">The arc that will be rendered.</param> /// <param name="angle">The angle along the original Arc at which the extruded radius is drawn.</param> /// <param name="local_angle">The angle at which the ray is "refracting" from the surface. 0=>right; PI/2=>up.</param> /// <param name="extrusion">The distance (radius) to extrude the radial arc.</param> /// <param name="color">The color of the drawn radial arc.</param> /// <param name="orientation">The Transform's rotation (for moving platforms). For static objects, use Quaternion.identity.</param> public static void draw_ray(Arc arc, float angle, float local_angle, float extrusion, Color color, Quaternion orientation) { Vector3 from = arc.position(angle); Vector3 to = ArcUtility.relative_point(arc, angle, local_angle, extrusion); Arc composite = ArcFactory.line(from, to); draw_arc(composite, 0.0f, color, orientation); }
private static optional <Vector3> closest_heuristic(HeuristicFunction distance_heuristic, Vector3 target) { List <Arc> arc_list = ArcUtility.get_all_arcs(); if (arc_list.Count > 0) { Vector3 closest_point = arc_list[0].begin(); float closest_distance_squared = Mathf.Infinity; foreach (Arc arc in arc_list) { Vector3 other_point = distance_heuristic(arc, target); float distance_squared = (other_point - target).sqrMagnitude; if (distance_squared < closest_distance_squared) { closest_distance_squared = distance_squared; closest_point = other_point; } } return(closest_point); } return(new optional <Vector3>()); }
public override Color32[] get_pixels(NormalizedCartesianCoordinates[] positions) { Color32[] colors = new Color32[positions.Length]; for (int index = 0; index < positions.Length; ++index) { Vector3 position = positions[index].data; if (Vector3.Dot(center, position) < dot_product_threshold) // circle check (is test point within circle circumscribing extruded arc?) { colors[index] = new Color32(0, 0, 0, 0); // Color.clear } else if (Mathf.Abs(Vector3.Dot(arc.center_axis, position) - center_offset) > center_range) // elevation check (is test point in narrow band of the arc?) { colors[index] = new Color32(0, 0, 0, 0); // Color.clear } else // common early returns handled, do expensive work { Vector3 closest_point = ArcUtility.snap_to_edge(arc, position); float angle = Vector3.Angle(position, closest_point) * Mathf.Deg2Rad; float falloff = Mathf.Clamp01(1f - angle / radius); // distance check (is test point closer than max radial distance?) - avoid negatives colors[index] = new Color(1, 1, 1, falloff); } } return(colors); }