public static Vector3[] arc_path_intersections(Arc arc, Vector3 begin, Vector3 end, float extrusion) { SphericalCap arc_circle = arc.floor(extrusion).collider(); SphericalCap path_circle = SphericalCap.cap(Vector3.Cross(begin, end).normalized, 0); Vector3[] intersections = circle_circle_intersections(arc_circle, path_circle); return(valid_arc_intersections(arc, intersections, Quaternion.identity)); }
public static Vector3[] raycast_intersection(Arc raycast_arc, Arc geometry_arc, float raycast_angle, Quaternion orientation) { SphericalCap relative_geometry_circle = geometry_arc.floor().collider(); if (orientation != Quaternion.identity) { Quaternion arc_to_world = orientation; Debug.DrawRay(Vector3.zero, relative_geometry_circle.normal, Color.green, 1f); relative_geometry_circle = SphericalCap.cap(arc_to_world * relative_geometry_circle.normal, relative_geometry_circle.offset); Debug.DrawRay(Vector3.zero, relative_geometry_circle.normal, Color.cyan, 1f); } Vector3[] intersections = circle_circle_intersections(raycast_arc.floor().collider(), relative_geometry_circle); intersections = valid_arc_intersections(raycast_arc, intersections, Quaternion.identity, raycast_angle); intersections = valid_arc_intersections(geometry_arc, intersections, orientation); return(intersections); }
internal static PlanetariaSphereCollider boundary_collider(Vector3 center_axis, Vector3 point) { PlanetariaSphereCollider result; SphericalCap cap = SphericalCap.cap(center_axis, point); // create a SphericalCap centered at "center" that captures both corners (2nd implicitly) float real_angle = Vector3.Angle(center_axis, point) * Mathf.Deg2Rad; if (real_angle < Precision.max_sphere_radius) // use a r<=1 sphere { result = PlanetariaArcColliderUtility.ideal_collider(cap); } else // use r=2 sphere { result = PlanetariaArcColliderUtility.uniform_collider(cap); } if (result.radius < Precision.threshold) { return(new PlanetariaSphereCollider(center_axis, 0)); } return(result); }
/// <summary> /// Inspector - Creates a SphericalCap that represents the floor (at given elevation). /// </summary> /// <param name="extrusion">The radius of the collider touching the floor.</param> /// <returns>A SphericalCap representing the floor. Normal goes "down" - towards floor.</returns> // FIXME: (?) unintuitive normal public SphericalCap floor(float extrusion = 0) { return(SphericalCap.cap(center_axis, Mathf.Sin(arc_latitude + extrusion)).complement()); }