Search Results for

    Show / Hide Table of Contents

    Struct Ray

    Represents a three dimensional line based on a point in space and a direction.

    Assembly: FlaxEngine.dll
    File: Engine/Core/Math/Ray.h
    Syntax
    public struct Ray

    Constructors

    Ray()

    Empty constructor.

    Declaration
    public Ray() = default

    Ray(const Vector3& position, const Vector3& direction)

    Initializes a new instance of the Ray struct.

    Declaration
    public Ray(const Vector3& position, const Vector3& direction)
    Parameters
    Vector3 position

    The ray origin position in 3D space.

    Vector3 direction

    The normalized ray direction in 3D space.

    Fields

    Direction

    The normalized direction in which the ray points.

    Declaration
    public Vector3 Direction
    Field Value
    Vector3

    Identity

    Identity ray (at zero origin pointing forwards).

    Declaration
    public static Ray Identity
    Field Value
    Ray

    Position

    The position in three dimensional space where the ray starts.

    Declaration
    public Vector3 Position
    Field Value
    Vector3

    Methods

    GetPickRay(float x, float y, const Viewport& viewport, const Matrix& vp)

    Calculates a world space ray from 2d screen coordinates.

    Declaration
    public static Ray GetPickRay(float x, float y, const Viewport& viewport, const Matrix& vp)
    Parameters
    float x

    The X coordinate on 2d screen.

    float y

    The Y coordinate on 2d screen.

    Viewport viewport

    The screen viewport.

    Matrix vp

    The View*Projection matrix.

    Returns
    Ray

    The resulting ray.

    GetPoint(Real distance)

    Gets a point at distance long ray.

    Declaration
    public Vector3 GetPoint(Real distance) const
    Parameters
    Real distance

    The distance from ray origin.

    Returns
    Vector3

    The calculated point.

    Intersects(const BoundingBox& box)

    Determines if there is an intersection between ray and a BoundingBox.

    Declaration
    public bool Intersects(const BoundingBox& box) const
    Parameters
    BoundingBox box

    The box to test.

    Returns
    bool

    Whether the two objects intersected.

    Intersects(const BoundingBox& box, Real& distance)

    Determines if there is an intersection between ray and a BoundingBox.

    Declaration
    public bool Intersects(const BoundingBox& box, Real& distance) const
    Parameters
    BoundingBox box

    The box to test.

    Real distance

    When the method completes, contains the distance of the intersection, or 0 if there was no intersection.

    Returns
    bool

    Whether the two objects intersected.

    Intersects(const BoundingBox& box, Vector3& point)

    Determines if there is an intersection between ray and a BoundingBox.

    Declaration
    public bool Intersects(const BoundingBox& box, Vector3& point) const
    Parameters
    BoundingBox box

    The box to test.

    Vector3 point

    When the method completes, contains the point of intersection, or Vector3.Zero if there was no intersection.

    Returns
    bool

    Whether the two objects intersected.

    Intersects(const BoundingSphere& sphere)

    Determines if there is an intersection between ray and a BoundingSphere.

    Declaration
    public bool Intersects(const BoundingSphere& sphere) const
    Parameters
    BoundingSphere sphere

    The sphere to test.

    Returns
    bool

    Whether the two objects intersected.

    Intersects(const BoundingSphere& sphere, Real& distance)

    Determines if there is an intersection between ray and a BoundingSphere.

    Declaration
    public bool Intersects(const BoundingSphere& sphere, Real& distance) const
    Parameters
    BoundingSphere sphere

    The sphere to test.

    Real distance

    When the method completes, contains the distance of the intersection, or 0 if there was no intersection.

    Returns
    bool

    Whether the two objects intersected.

    Intersects(const BoundingSphere& sphere, Vector3& point)

    Determines if there is an intersection between ray and a BoundingSphere.

    Declaration
    public bool Intersects(const BoundingSphere& sphere, Vector3& point) const
    Parameters
    BoundingSphere sphere

    The sphere to test.

    Vector3 point

    When the method completes, contains the point of intersection, or Vector3.Zero if there was no intersection.

    Returns
    bool

    Whether the two objects intersected.

    Intersects(const Plane& plane)

    Determines if there is an intersection between ray and a Plane.

    Declaration
    public bool Intersects(const Plane& plane) const
    Parameters
    Plane plane

    The plane to test

    Returns
    bool

    Whether the two objects intersected.

    Intersects(const Plane& plane, Real& distance)

    Determines if there is an intersection between ray and a Plane.

    Declaration
    public bool Intersects(const Plane& plane, Real& distance) const
    Parameters
    Plane plane

    The plane to test.

    Real distance

    When the method completes, contains the distance of the intersection, or 0 if there was no intersection.

    Returns
    bool

    Whether the two objects intersected.

    Intersects(const Plane& plane, Vector3& point)

    Determines if there is an intersection between ray and a Plane.

    Declaration
    public bool Intersects(const Plane& plane, Vector3& point) const
    Parameters
    Plane plane

    The plane to test.

    Vector3 point

    When the method completes, contains the point of intersection, or Vector3.Zero if there was no intersection.

    Returns
    bool

    Whether the two objects intersected.

    Intersects(const Ray& ray)

    Determines if there is an intersection between two rays.

    Declaration
    public bool Intersects(const Ray& ray) const
    Parameters
    Ray ray

    The ray to test.

    Returns
    bool

    Whether the two objects intersected.

    Intersects(const Ray& ray, Vector3& point)

    Determines if there is an intersection between ray and a Ray.

    Declaration
    public bool Intersects(const Ray& ray, Vector3& point) const
    Parameters
    Ray ray

    The ray to test.

    Vector3 point

    When the method completes, contains the point of intersection, or Vector3.Zero if there was no intersection.

    Returns
    bool

    Whether the two objects intersected.

    Intersects(const Vector3& point)

    Determines if there is an intersection between ray and a point.

    Declaration
    public bool Intersects(const Vector3& point) const
    Parameters
    Vector3 point

    The point to test.

    Returns
    bool

    Whether the two objects intersected.

    Intersects(const Vector3& vertex1, const Vector3& vertex2, const Vector3& vertex3)

    Determines if there is an intersection between ray and a triangle.

    Declaration
    public bool Intersects(const Vector3& vertex1, const Vector3& vertex2, const Vector3& vertex3) const
    Parameters
    Vector3 vertex1

    The first vertex of the triangle to test.

    Vector3 vertex2

    The second vertex of the triangle to test.

    Vector3 vertex3

    The third vertex of the triangle to test.

    Returns
    bool

    Whether the two objects intersected.

    Intersects(const Vector3& vertex1, const Vector3& vertex2, const Vector3& vertex3, Real& distance)

    Determines if there is an intersection between ray and a triangle.

    Declaration
    public bool Intersects(const Vector3& vertex1, const Vector3& vertex2, const Vector3& vertex3, Real& distance) const
    Parameters
    Vector3 vertex1

    The first vertex of the triangle to test.

    Vector3 vertex2

    The second vertex of the triangle to test.

    Vector3 vertex3

    The third vertex of the triangle to test.

    Real distance

    When the method completes, contains the distance of the intersection, or 0 if there was no intersection.

    Returns
    bool

    Whether the two objects intersected.

    Intersects(const Vector3& vertex1, const Vector3& vertex2, const Vector3& vertex3, Vector3& point)

    Determines if there is an intersection between ray and a triangle.

    Declaration
    public bool Intersects(const Vector3& vertex1, const Vector3& vertex2, const Vector3& vertex3, Vector3& point) const
    Parameters
    Vector3 vertex1

    The first vertex of the triangle to test.

    Vector3 vertex2

    The second vertex of the triangle to test.

    Vector3 vertex3

    The third vertex of the triangle to test.

    Vector3 point

    When the method completes, contains the point of intersection, or Vector3.Zero if there was no intersection.

    Returns
    bool

    Whether the two objects intersected.

    NearEqual(const Ray& a, const Ray& b)

    Declaration
    public static bool NearEqual(const Ray& a, const Ray& b)
    Parameters
    Ray a

    Ray b

    Returns
    bool

    NearEqual(const Ray& a, const Ray& b, Real epsilon)

    Declaration
    public static bool NearEqual(const Ray& a, const Ray& b, Real epsilon)
    Parameters
    Ray a

    Ray b

    Real epsilon

    Returns
    bool

    operator!=(const Ray& other)

    Declaration
    public bool operator!=(const Ray& other) const
    Parameters
    Ray other

    Returns
    bool

    operator==(const Ray& other)

    Declaration
    public bool operator==(const Ray& other) const
    Parameters
    Ray other

    Returns
    bool

    ToString()

    Declaration
    public String ToString() const
    Returns
    String

    • Improve this Doc
    • View Source
    In This Article
    Back to top Copyright © 2012-2024 Wojciech Figat