1 | <?php |
||
13 | class LineSegment implements Finite |
||
14 | { |
||
15 | /** @type \Nubs\Geometron\Point One endpoint of the line segment. */ |
||
16 | protected $_a; |
||
17 | |||
18 | /** @type \Nubs\Geometron\Point One endpoint of the line segment. */ |
||
19 | protected $_b; |
||
20 | |||
21 | /** |
||
22 | * Initalize the line segment with its two endpoints. |
||
23 | * |
||
24 | * @api |
||
25 | * @param \Nubs\Geometron\Point $a One endpoint of the line segment. |
||
26 | * @param \Nubs\Geometron\Point $b One endpoint of the line segment. |
||
27 | */ |
||
28 | public function __construct(Point $a, Point $b) |
||
37 | |||
38 | /** |
||
39 | * Get an endpoint of the line segment. |
||
40 | * |
||
41 | * @api |
||
42 | * @return \Nubs\Geometron\Point One endpoint of the line segment. |
||
43 | */ |
||
44 | public function a() |
||
48 | |||
49 | /** |
||
50 | * Get an endpoint of the line segment. |
||
51 | * |
||
52 | * @api |
||
53 | * @return \Nubs\Geometron\Point One endpoint of the line segment. |
||
54 | */ |
||
55 | public function b() |
||
59 | |||
60 | /** |
||
61 | * Determine whether this line segment is degenerate. |
||
62 | * |
||
63 | * A line segment is degenerate if its two points are the same. |
||
64 | * |
||
65 | * @api |
||
66 | * @return bool True if the line segment is degenerate, false otherwise. |
||
67 | */ |
||
68 | public function isDegenerate() |
||
72 | |||
73 | /** |
||
74 | * Calculates the vector between the two endpoints of the line segment. |
||
75 | * |
||
76 | * @api |
||
77 | * @return \Nubs\Vectorix\Vector The vector from a() to b(). |
||
78 | */ |
||
79 | public function vector() |
||
83 | |||
84 | /** |
||
85 | * Calculates the length of the line segment. |
||
86 | * |
||
87 | * @api |
||
88 | * @return float The length of the line segment. |
||
89 | */ |
||
90 | public function length() |
||
94 | |||
95 | /** |
||
96 | * The center of a line segment is the point halfway along the line. |
||
97 | * |
||
98 | * @api |
||
99 | * @return \Nubs\Geometron\Point The center-point of the line segment. |
||
100 | * @see \Nubs\Geometron\Finite::center() |
||
101 | */ |
||
102 | public function center() |
||
106 | } |
||
107 |