3
@c This file is part of the 3DLDF User and Reference Manual.
4
@c Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 The Free Software Foundation
5
@c See the section "GNU Free Documentation License" in the file
6
@c fdl.texi for copying conditions.
9
@node Line Reference, Plane Reference, Focus Reference, Top
10
@chapter Line Reference
13
The @code{struct Line} is defined in @file{lines.web}.
14
@code{Lines} are not @code{Shapes}. They are used for
15
performing vector operations. A @code{Line} is defined by a
16
@code{Point} representing a position vector and a @code{Point}
17
representing a direction vector.
19
See also the descriptions of @code{Point::get_line()} in
20
@ref{Points and Lines}, and
21
@code{Path::get_line()} in
22
@ref{Querying Paths,,Path Reference; Querying}.
27
* Line Global Constants::
34
@node Line Data Members, Line Global Constants, Line Reference, Line Reference
37
@deftypevr {Public variable} Point position
38
Represents the position vector of the @code{Line}.
41
@deftypevr {Public variable} Point direction
42
Represents the direction vector of the @code{Line}.
45
@node Line Global Constants, Line Constructors, Line Data Members, Line Reference
46
@section Global Constants
47
@deftypevr {Constant} {const Line} INVALID_LINE
48
@code{position} and @code{direction} are both @code{INVALID_POINT}.
51
@node Line Constructors, Line Operators, Line Global Constants, Line Reference
54
@deftypefn {Default constructor} void Line ({const Point&} @var{pos} = @code{origin}, {const Point&} @var{dir} = @code{origin})
55
Creates a @code{Line}, setting @code{position} to @var{pos}, and
56
@code{direction} to @var{dir}. If this function is called with no
57
arguments, it creates a @code{Line} at the @code{origin} with no
64
Line L1 = p.get_line(d);
72
\immediate\write\examples{default_focus.set(2, 3, -10, 0, 3, 10, 10);}
73
\immediate\write\examples{draw_axes(gray);}
74
\immediate\write\examples{stringstream s;}
75
\immediate\write\examples{Point p(2, 1, 2);}
76
\immediate\write\examples{Point d(-3, 3, 3.5);}
77
\immediate\write\examples{p.dotlabel("$p$"); }
78
\immediate\write\examples{p.label(Point::WORLD_VALUES, "bot");}
79
\immediate\write\examples{p.draw(d, black, "evenly");}
80
\immediate\write\examples{Line L0(p, d);}
81
\immediate\write\examples{s << "$d @DBKS{equiv} L_0.@OCB@DBKS{tt} direction@CCB @DBKS{equiv} (" }
82
\immediate\write\examples{ << L0.direction.get_x()}
83
\immediate\write\examples{ << ", " << L0.direction.get_y() << ", " << L0.direction.get_z()}
84
\immediate\write\examples{ << ")$";}
85
\immediate\write\examples{L0.direction.label(s.str()); }
86
\immediate\write\examples{origin.drawarrow(L0.direction);}
87
\immediate\write\examples{Line L1 = p.get_line(d);}
88
\immediate\write\examples{s.str("");}
89
\immediate\write\examples{s << "$L_1.@OCB@DBKS{tt} direction@CCB @DBKS{equiv} (" << L1.direction.get_x()}
90
\immediate\write\examples{ << ", " << L1.direction.get_y() << ", " << L1.direction.get_z()}
91
\immediate\write\examples{ << ")$";}
92
\immediate\write\examples{L1.direction.label(s.str());}
93
\immediate\write\examples{origin.drawarrow(L1.direction); }
106
<img src="./graphics/png/3DLDF104.png"
107
alt="[Figure 104. Not displayed.]"
118
[Figure 104 not displayed.]
123
@deftypefn {Copy constructor} void Line ({const Line&} @var{l})
124
Creates a @code{Line}, making it a copy of @var{l}.
128
@node Line Operators, Get Path, Line Constructors, Line Reference
131
@deftypefn {Assignment operator} void operator= ({const Line&} @var{l})
132
Sets @code{*this} to @var{l}.
135
@c LDF 2003.06.03. Add description of @code{get_distance()}, when I've
138
@node Get Path, Showing, Line Operators, Line Reference
141
@deftypefn {@code{const} function} Path get_path (void)
142
Returns a linear @code{Path} with two @code{Points}
143
on the @code{Line}. The first @code{Point} will be @code{position}, and
144
the second will be @code{position + direction}.
147
@node Showing, , Get Path, Line Reference
150
@deftypefun void show ([string @var{text} = ""])
151
If @var{text} is not the empty @code{string} (the default), it is
152
printed on a line of its own to standard output. Otherwise, @samp{Line:}
153
is printed. Following this, @code{Point::show()} is called on
154
@code{position} and @code{direction}.
158
Point d(-12.3, 21, 36.002);
163
direction: (-12.3, 21, 36.002)
164
Line L1 = p.get_line(d);
168
direction: (-13.3, 23, 33.002)
169
Path q = L1.get_path();
173
(1, -2, 3) -- (-12.3, 21, 36.002);