template struct geom::LineSegment — HIRO 0.7.0 documentation

# template struct geom::LineSegment

## Overview

Template line segment in an arbitrary dimension. More…

    #include <GeometryStructures.h>

    template <size_t N>
    struct LineSegment {
        // typedefs

        typedef glm::vec<N, float> Vec;

        // fields

        Vec point1;
        Vec point2;

        // construction

        LineSegment();
        LineSegment(const Vec& init_point1, const Vec& init_point2);

        // methods

        float GetLength() const;
        float GetLengthSqr() const;
        Vec GetDirection() const;
        Vec ToVector() const;
    };

## Detailed Documentation

Template line segment in an arbitrary dimension.

### Methods

    float GetLength() const

Returns length of line segment = distance between point1 and point2.

    float GetLengthSqr() const

Returns square length of line segment = square distance between point1 and point2.

    Vec GetDirection() const

Returns direction of the line as a normalized vector from point1 to point2.

    Vec ToVector() const

Converts the line to the vector from point1 to point2.