Ray

public class Ray

An object representing a set of straight lines originating from a point.

The Ray may be modified by intersecting it with other Shapes

  • The position of the ray

    Declaration

    Swift

    public var origin: Vector
  • The direction of the ray

    Declaration

    Swift

    public var direction: Vector
  • The path the ray has taken

    Declaration

    Swift

    public var path: [Line]
  • Whether or no the ray is terminated

    If this value is true no more tracing will be done

    Declaration

    Swift

    public var isTerminated: Bool
  • Instantiate a new Ray.

    Declaration

    Swift

    public init(origin: Vector, direction: Vector)

    Parameters

    origin

    The position of the Ray

    direction

    The direction of the Ray

  • Instantiate a new Ray.

    Declaration

    Swift

    public convenience init(x: Double, y: Double, direction: Degrees)

    Parameters

    x

    The X position of the Ray.

    y

    The Y position of the Ray.

    direction

    The direction of the Ray, in degrees.

  • Remove the ray’s saved path and reset its iterations

    Declaration

    Swift

    public func resetPath()
  • Stop the receiver from continuing to trace new paths.

    Declaration

    Swift

    public func terminateRay()
  • Perform the ray tracing operation.

    Declaration

    Swift

    public func run(objects: [RayTracable])

    Parameters

    objects

    The objects to trace against.

  • Draw the emitter and ray trace using the specified objects

    Declaration

    Swift

    public func draw()

    Parameters

    objects

    Objects to test for intersection when casting rays

  • Draws a representation of the emitter suitable for debugging.

    Declaration

    Swift

    public func debugDraw(in context: CGContext)

    Parameters

    context

    Context in which to draw