File: Ray.py

package info (click to toggle)
uranium 5.0.0-7
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 5,304 kB
  • sloc: python: 31,765; sh: 132; makefile: 12
file content (29 lines) | stat: -rw-r--r-- 838 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# Copyright (c) 2015 Ultimaker B.V.
# Uranium is released under the terms of the LGPLv3 or higher.

from UM.Math.Vector import Vector


class Ray:
    def __init__(self, origin: Vector = Vector(), direction: Vector = Vector()) -> None:
        self._origin = origin
        self._direction = direction
        self._inverse_direction = 1.0 / direction

    @property
    def origin(self) -> Vector:
        return self._origin

    @property
    def direction(self) -> Vector:
        return self._direction

    @property
    def inverseDirection(self) -> Vector:
        return self._inverse_direction

    def getPointAlongRay(self, distance: float) -> Vector:
        return self._origin + (self._direction * distance)

    def __repr__(self):
        return "Ray(origin = {0}, direction = {1})".format(self._origin, self._direction)