DGtal
0.6.devel
Main Page
Related Pages
Modules
Namespaces
Data Structures
Examples
All
Data Structures
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Groups
Pages
src
DGtal
shapes
fromPoints
StraightLineFrom2Points.ih
1
30
31
#include <cstdlib>
33
35
// IMPLEMENTATION of inline methods.
37
39
// ----------------------- Standard services ------------------------------
40
41
template
<
typename
TPo
int
>
42
inline
43
DGtal::StraightLineFrom2Points<TPoint>::~StraightLineFrom2Points
()
44
{
45
}
46
47
template
<
typename
TPo
int
>
48
inline
49
DGtal::StraightLineFrom2Points<TPoint>::StraightLineFrom2Points
()
50
{
51
}
52
53
template
<
typename
TPo
int
>
54
inline
55
void
56
DGtal::StraightLineFrom2Points<TPoint>::init
(
57
const
Point
& aFirstPoint,
58
const
Point
& aSecondPoint)
59
{
60
myP = aFirstPoint;
61
myQ = aSecondPoint;
62
}
63
64
65
template
<
typename
TPo
int
>
66
inline
67
DGtal::StraightLineFrom2Points<TPoint>::StraightLineFrom2Points
(
68
const
Point
& aFirstPoint,
69
const
Point
& aSecondPoint):
70
myP(aFirstPoint),
71
myQ(aSecondPoint)
72
{
73
}
74
75
76
template
<
typename
TPo
int
>
77
inline
78
DGtal::StraightLineFrom2Points<TPoint>::StraightLineFrom2Points
(
79
const
StraightLineFrom2Points
& other):
80
myP(other.myP),
81
myQ(other.myQ)
82
{
83
}
84
85
86
template
<
typename
TPo
int
>
87
inline
88
DGtal::StraightLineFrom2Points<TPoint>
&
89
DGtal::StraightLineFrom2Points<TPoint>::operator=
(
90
const
StraightLineFrom2Points
& other)
91
{
92
myP = other.
myP
;
93
myQ = other.
myQ
;
94
return
*
this
;
95
}
96
97
98
99
template
<
typename
TPo
int
>
100
inline
101
typename
DGtal::StraightLineFrom2Points<TPoint>::Distance
102
DGtal::StraightLineFrom2Points<TPoint>::signedDistance
(
const
Point
& aP)
const
103
{
104
Vector
pq = myQ - myP;
105
Vector
pr = aP - myP;
106
//computation of det(pq, pr)
107
//(= twice the parallelogram area)
108
return
((pq.at(0) * pr.at(1)) - (pq.at(1) * pr.at(0)));
109
}
110
111
113
// Interface - public :
114
115
template
<
typename
TPo
int
>
116
inline
117
std::string
118
DGtal::StraightLineFrom2Points<TPoint>::className
()
const
119
{
120
return
"StraightLineFrom2Points"
;
121
}
122
123
template
<
typename
TPo
int
>
124
inline
125
void
126
DGtal::StraightLineFrom2Points<TPoint>::selfDisplay
( std::ostream & out )
const
127
{
128
out <<
"[StraightLineFrom2Points] passing through:\n"
;
129
out << myP << myQ;
130
}
131
132
template
<
typename
TPo
int
>
133
inline
134
bool
135
DGtal::StraightLineFrom2Points<TPoint>::isValid
()
const
136
{
137
return
true
;
138
}
139
140
Generated on Wed Dec 19 2012 19:10:36 for DGtal by
1.8.1.1