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
e611d110
Commit
e611d110
authored
Feb 14, 2015
by
Davis King
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Made the mapping from rectangle -> drectangle -> rectangle invertible.
parent
c632db76
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
16 deletions
+27
-16
drectangle.h
dlib/geometry/drectangle.h
+10
-9
drectangle_abstract.h
dlib/geometry/drectangle_abstract.h
+17
-7
No files found.
dlib/geometry/drectangle.h
View file @
e611d110
...
...
@@ -56,18 +56,18 @@ namespace dlib
drectangle
(
const
rectangle
&
rect
)
:
l
(
rect
.
left
()),
t
(
rect
.
top
()),
r
(
rect
.
right
()),
b
(
rect
.
bottom
())
{}
)
:
l
(
rect
.
left
()
-
0
.
5
),
t
(
rect
.
top
()
-
0
.
5
),
r
(
rect
.
right
()
+
0
.
5
),
b
(
rect
.
bottom
()
+
0
.
5
)
{}
operator
rectangle
(
)
const
{
return
rectangle
((
long
)
std
::
floor
(
l
+
0
.
5
),
(
long
)
std
::
floor
(
t
+
0
.
5
),
(
long
)
std
::
floor
(
r
+
0
.
5
),
(
long
)
std
::
floor
(
b
+
0
.
5
));
return
rectangle
((
long
)
std
::
ceil
(
l
),
(
long
)
std
::
ceil
(
t
),
(
long
)
std
::
floor
(
r
),
(
long
)
std
::
floor
(
b
));
}
double
left
()
const
{
return
l
;
}
...
...
@@ -334,9 +334,10 @@ namespace dlib
return
r
+
drectangle
(
p
);
}
template
<
typename
T
>
inline
drectangle
translate_rect
(
const
drectangle
&
rect
,
const
dlib
::
vector
<
double
,
2
>&
p
const
dlib
::
vector
<
T
,
2
>&
p
)
{
drectangle
result
;
...
...
dlib/geometry/drectangle_abstract.h
View file @
e611d110
...
...
@@ -91,18 +91,27 @@ namespace dlib
);
/*!
ensures
- left() == rect.left()
- top() == rect.top()
- right() == rect.right()
- bottom() == rect.bottom()
- left() == rect.left()-0.5
- top() == rect.top()-0.5
- right() == rect.right()+0.5
- bottom() == rect.bottom()+0.5
- center(*this) == center(rect)
- width() == rect.width()
- height() == rect.height()
!*/
operator
rectangle
(
)
const
;
/*!
ensures
- rounds the left, top, right, and bottom coordinates of *this to the
nearest integers and returns the resulting rectangle.
- returns a rectangle R such that:
- R.left() == ceil(left())
- R.top() == ceil(top())
- R.right() == floor(right())
- R.bottom() == floor(bottom())
- This function is designed this way so that converting a rectangle to a
drectangle and then back to a rectangle again results in the original
rectangle.
!*/
double
left
(
...
...
@@ -435,9 +444,10 @@ namespace dlib
// ----------------------------------------------------------------------------------------
template
<
typename
T
>
drectangle
translate_rect
(
const
drectangle
&
rect
,
const
vector
<
double
,
2
>&
p
const
vector
<
T
,
2
>&
p
);
/*!
ensures
...
...
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