Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
dlib
Commits
e611d110
Commit
e611d110
authored
Feb 14, 2015
by
Davis King
Browse files
Made the mapping from rectangle -> drectangle -> rectangle invertible.
parent
c632db76
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
16 deletions
+27
-16
dlib/geometry/drectangle.h
dlib/geometry/drectangle.h
+10
-9
dlib/geometry/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
...
@@ -56,18 +56,18 @@ namespace dlib
drectangle
(
drectangle
(
const
rectangle
&
rect
const
rectangle
&
rect
)
:
l
(
rect
.
left
()),
)
:
l
(
rect
.
left
()
-
0.5
),
t
(
rect
.
top
()),
t
(
rect
.
top
()
-
0.5
),
r
(
rect
.
right
()),
r
(
rect
.
right
()
+
0.5
),
b
(
rect
.
bottom
())
{}
b
(
rect
.
bottom
()
+
0.5
)
{}
operator
rectangle
(
operator
rectangle
(
)
const
)
const
{
{
return
rectangle
((
long
)
std
::
floor
(
l
+
0.5
),
return
rectangle
((
long
)
std
::
ceil
(
l
),
(
long
)
std
::
floor
(
t
+
0.5
),
(
long
)
std
::
ceil
(
t
),
(
long
)
std
::
floor
(
r
+
0.5
),
(
long
)
std
::
floor
(
r
),
(
long
)
std
::
floor
(
b
+
0.5
));
(
long
)
std
::
floor
(
b
));
}
}
double
left
()
const
{
return
l
;
}
double
left
()
const
{
return
l
;
}
...
@@ -334,9 +334,10 @@ namespace dlib
...
@@ -334,9 +334,10 @@ namespace dlib
return
r
+
drectangle
(
p
);
return
r
+
drectangle
(
p
);
}
}
template
<
typename
T
>
inline
drectangle
translate_rect
(
inline
drectangle
translate_rect
(
const
drectangle
&
rect
,
const
drectangle
&
rect
,
const
dlib
::
vector
<
double
,
2
>&
p
const
dlib
::
vector
<
T
,
2
>&
p
)
)
{
{
drectangle
result
;
drectangle
result
;
...
...
dlib/geometry/drectangle_abstract.h
View file @
e611d110
...
@@ -91,18 +91,27 @@ namespace dlib
...
@@ -91,18 +91,27 @@ namespace dlib
);
);
/*!
/*!
ensures
ensures
- left() == rect.left()
- left() == rect.left()-0.5
- top() == rect.top()
- top() == rect.top()-0.5
- right() == rect.right()
- right() == rect.right()+0.5
- bottom() == rect.bottom()
- bottom() == rect.bottom()+0.5
- center(*this) == center(rect)
- width() == rect.width()
- height() == rect.height()
!*/
!*/
operator
rectangle
(
operator
rectangle
(
)
const
;
)
const
;
/*!
/*!
ensures
ensures
- rounds the left, top, right, and bottom coordinates of *this to the
- returns a rectangle R such that:
nearest integers and returns the resulting rectangle.
- 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
(
double
left
(
...
@@ -435,9 +444,10 @@ namespace dlib
...
@@ -435,9 +444,10 @@ namespace dlib
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
template
<
typename
T
>
drectangle
translate_rect
(
drectangle
translate_rect
(
const
drectangle
&
rect
,
const
drectangle
&
rect
,
const
vector
<
double
,
2
>&
p
const
vector
<
T
,
2
>&
p
);
);
/*!
/*!
ensures
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