Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
K
kicad-source-mirror
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
Elphel
kicad-source-mirror
Commits
84239542
Commit
84239542
authored
Apr 05, 2013
by
Maciej Suminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed code formatting.
parent
6d088b43
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
50 additions
and
46 deletions
+50
-46
vector2d.h
include/math/vector2d.h
+50
-46
No files found.
include/math/vector2d.h
View file @
84239542
...
@@ -65,8 +65,8 @@ std::ostream& operator<<( std::ostream& stream, const VECTOR2<T>& vector );
...
@@ -65,8 +65,8 @@ std::ostream& operator<<( std::ostream& stream, const VECTOR2<T>& vector );
* Class VECTOR2
* Class VECTOR2
* defines a general 2D-vector/point.
* defines a general 2D-vector/point.
*
*
* This class uses templates to be universal. Several operators are provided to help
easy implementing
* This class uses templates to be universal. Several operators are provided to help
* of linear algebra equations.
*
easy implementing
of linear algebra equations.
*
*
*/
*/
template
<
class
T
=
int
>
template
<
class
T
=
int
>
...
@@ -153,7 +153,8 @@ public:
...
@@ -153,7 +153,8 @@ public:
* the side of the line at which we are (negative = left)
* the side of the line at which we are (negative = left)
* @return the distance
* @return the distance
*/
*/
T
LineDistance
(
const
VECTOR2
<
T
>&
aStart
,
const
VECTOR2
<
T
>&
aEnd
,
bool
aDetermineSide
=
false
)
const
;
T
LineDistance
(
const
VECTOR2
<
T
>&
aStart
,
const
VECTOR2
<
T
>&
aEnd
,
bool
aDetermineSide
=
false
)
const
;
/**
/**
* Function ClosestSegmentPoint
* Function ClosestSegmentPoint
...
@@ -368,19 +369,21 @@ VECTOR2<T> VECTOR2<T>::LineProjection( const VECTOR2<T>& aA, const VECTOR2<T>& a
...
@@ -368,19 +369,21 @@ VECTOR2<T> VECTOR2<T>::LineProjection( const VECTOR2<T>& aA, const VECTOR2<T>& a
template
<
class
T
>
template
<
class
T
>
T
VECTOR2
<
T
>::
LineDistance
(
const
VECTOR2
<
T
>&
aStart
,
const
VECTOR2
<
T
>&
aEnd
,
bool
aDetermineSide
)
const
T
VECTOR2
<
T
>::
LineDistance
(
const
VECTOR2
<
T
>&
aStart
,
const
VECTOR2
<
T
>&
aEnd
,
bool
aDetermineSide
)
const
{
{
extended_type
a
=
aStart
.
y
-
aEnd
.
y
;
extended_type
a
=
aStart
.
y
-
aEnd
.
y
;
extended_type
b
=
aEnd
.
x
-
aStart
.
x
;
extended_type
b
=
aEnd
.
x
-
aStart
.
x
;
extended_type
c
=
-
a
*
aStart
.
x
-
b
*
aStart
.
y
;
extended_type
c
=
-
a
*
aStart
.
x
-
b
*
aStart
.
y
;
T
dist
=
(
a
*
x
+
b
*
y
+
c
)
/
sqrt
(
a
*
a
+
b
*
b
);
T
dist
=
(
a
*
x
+
b
*
y
+
c
)
/
sqrt
(
a
*
a
+
b
*
b
);
return
aDetermineSide
?
dist
:
abs
(
dist
);
return
aDetermineSide
?
dist
:
abs
(
dist
);
}
}
template
<
class
T
>
template
<
class
T
>
VECTOR2
<
T
>
VECTOR2
<
T
>::
ClosestSegmentPoint
(
const
VECTOR2
<
T
>&
aStart
,
const
VECTOR2
<
T
>&
aEnd
)
const
VECTOR2
<
T
>
VECTOR2
<
T
>::
ClosestSegmentPoint
(
const
VECTOR2
<
T
>&
aStart
,
const
VECTOR2
<
T
>&
aEnd
)
const
{
{
VECTOR2
<
T
>
d
=
(
aEnd
-
aStart
);
VECTOR2
<
T
>
d
=
(
aEnd
-
aStart
);
extended_type
l_squared
=
(
extended_type
)
d
.
x
*
d
.
x
+
(
extended_type
)
d
.
y
*
d
.
y
;
extended_type
l_squared
=
(
extended_type
)
d
.
x
*
d
.
x
+
(
extended_type
)
d
.
y
*
d
.
y
;
...
@@ -410,7 +413,7 @@ VECTOR2<T> VECTOR2<T>::ClosestSegmentPoint( const VECTOR2<T>& aStart, const VECT
...
@@ -410,7 +413,7 @@ VECTOR2<T> VECTOR2<T>::ClosestSegmentPoint( const VECTOR2<T>& aStart, const VECT
/*VECTOR2<T> proj = aStart + VECTOR2<T> ( ( t * (extended_type) d.x / l_squared ),
/*VECTOR2<T> proj = aStart + VECTOR2<T> ( ( t * (extended_type) d.x / l_squared ),
( t * ( extended_type) d.y / l_squared ) );*/
( t * ( extended_type) d.y / l_squared ) );*/
VECTOR2
<
T
>
proj
=
aStart
+
VECTOR2
<
T
>
(
(
T
)
xp
,
(
T
)
yp
);
VECTOR2
<
T
>
proj
=
aStart
+
VECTOR2
<
T
>
(
(
T
)
xp
,
(
T
)
yp
);
return
proj
;
return
proj
;
}
}
...
@@ -612,6 +615,7 @@ std::ostream& operator<<( std::ostream& aStream, const VECTOR2<T>& aVector )
...
@@ -612,6 +615,7 @@ std::ostream& operator<<( std::ostream& aStream, const VECTOR2<T>& aVector )
return
aStream
;
return
aStream
;
}
}
/* Default specializations */
/* Default specializations */
typedef
VECTOR2
<
double
>
VECTOR2D
;
typedef
VECTOR2
<
double
>
VECTOR2D
;
typedef
VECTOR2
<
int
>
VECTOR2I
;
typedef
VECTOR2
<
int
>
VECTOR2I
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment