struct CCL::Ray3D

Overview

3D Ray with an origin and direction in 3D space. More…

#include <ray3d.h>

struct Ray3D
{
    // fields

    PointF3D origin;
    PointF3D direction;

    // construction

    Ray3D (PointF3DRef origin = {}, PointF3DRef direction = {});

    // methods

    PointF3D operator * (float t) const;
    bool intersectsSphere (float& hitDistance, PointF3DRef center, float radius) const;
};

Detailed Documentation

3D Ray with an origin and direction in 3D space.

Methods

PointF3D operator * (float t) const

Get the point on the ray at a given distance.

bool intersectsSphere (float& hitDistance, PointF3DRef center, float radius) const

Test whether this ray intersects a sphere.

The return value indicates whether an intersection occurs. The hitDistance out-parameter is the distance to the first intersection, or 0 if the ray’s origin lies inside the sphere.