Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
D
dlib
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
钟尚武
dlib
Commits
1940012f
Commit
1940012f
authored
Feb 27, 2012
by
Davis King
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added the point_transform object
parent
f3efbc31
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
67 additions
and
0 deletions
+67
-0
vector.h
dlib/geometry/vector.h
+32
-0
vector_abstract.h
dlib/geometry/vector_abstract.h
+35
-0
No files found.
dlib/geometry/vector.h
View file @
1940012f
...
@@ -1287,6 +1287,38 @@ namespace dlib
...
@@ -1287,6 +1287,38 @@ namespace dlib
double
cos_angle
;
double
cos_angle
;
};
};
// ----------------------------------------------------------------------------------------
class
point_transform
{
public
:
point_transform
(
const
double
&
angle
,
const
dlib
::
vector
<
double
,
2
>&
translate_
)
{
sin_angle
=
std
::
sin
(
angle
);
cos_angle
=
std
::
cos
(
angle
);
translate
=
translate_
;
}
template
<
typename
T
>
const
dlib
::
vector
<
T
,
2
>
operator
()
(
const
dlib
::
vector
<
T
,
2
>&
p
)
const
{
double
x
=
cos_angle
*
p
.
x
()
-
sin_angle
*
p
.
y
();
double
y
=
sin_angle
*
p
.
x
()
+
cos_angle
*
p
.
y
();
return
dlib
::
vector
<
double
,
2
>
(
x
,
y
)
+
translate
;
}
private
:
double
sin_angle
;
double
cos_angle
;
dlib
::
vector
<
double
,
2
>
translate
;
};
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
template
<
typename
T
>
template
<
typename
T
>
...
...
dlib/geometry/vector_abstract.h
View file @
1940012f
...
@@ -431,6 +431,41 @@ namespace dlib
...
@@ -431,6 +431,41 @@ namespace dlib
typedef
vector
<
long
,
2
>
point
;
typedef
vector
<
long
,
2
>
point
;
// ----------------------------------------------------------------------------------------
class
point_transform
{
/*!
WHAT THIS OBJECT REPRESENTS
This is an object that takes 2D points or vectors and
rotates them around the origin by a given angle and then
translates them.
!*/
public
:
point_transform
(
const
double
&
angle
,
const
dlib
::
vector
<
double
,
2
>&
translate
)
/*!
ensures
- When (*this)(p) is invoked it will return a point P such that:
- P is the point p rotated counter-clockwise around the origin
angle radians and then shifted by having translate added to it.
(Note that this is counter clockwise with respect to the normal
coordinate system with positive y going up and positive x going
to the right)
!*/
template
<
typename
T
>
const
dlib
::
vector
<
T
,
2
>
operator
()
(
const
dlib
::
vector
<
T
,
2
>&
p
)
const
;
/*!
ensures
- rotates p, then translates it and returns the result
!*/
};
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
class
point_rotator
class
point_rotator
...
...
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