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
6adfdac9
Commit
6adfdac9
authored
Feb 02, 2015
by
Davis King
Browse files
Added shrink_rect() and grow_rect() for drectangle objects.
parent
43e29a07
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
85 additions
and
0 deletions
+85
-0
dlib/geometry/drectangle.h
dlib/geometry/drectangle.h
+34
-0
dlib/geometry/drectangle_abstract.h
dlib/geometry/drectangle_abstract.h
+51
-0
No files found.
dlib/geometry/drectangle.h
View file @
6adfdac9
...
@@ -365,6 +365,40 @@ namespace dlib
...
@@ -365,6 +365,40 @@ namespace dlib
return
drectangle
(
p
.
x
()
-
width
/
2
,
p
.
y
()
-
height
/
2
,
p
.
x
()
+
width
/
2
,
p
.
y
()
+
height
/
2
);
return
drectangle
(
p
.
x
()
-
width
/
2
,
p
.
y
()
-
height
/
2
,
p
.
x
()
+
width
/
2
,
p
.
y
()
+
height
/
2
);
}
}
inline
const
drectangle
shrink_rect
(
const
drectangle
&
rect
,
double
num
)
{
return
drectangle
(
rect
.
left
()
+
num
,
rect
.
top
()
+
num
,
rect
.
right
()
-
num
,
rect
.
bottom
()
-
num
);
}
inline
const
drectangle
grow_rect
(
const
drectangle
&
rect
,
double
num
)
{
return
shrink_rect
(
rect
,
-
num
);
}
inline
const
drectangle
shrink_rect
(
const
drectangle
&
rect
,
double
width
,
double
height
)
{
return
drectangle
(
rect
.
left
()
+
width
,
rect
.
top
()
+
height
,
rect
.
right
()
-
width
,
rect
.
bottom
()
-
height
);
}
inline
const
drectangle
grow_rect
(
const
drectangle
&
rect
,
double
width
,
double
height
)
{
return
shrink_rect
(
rect
,
-
width
,
-
height
);
}
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
}
}
...
...
dlib/geometry/drectangle_abstract.h
View file @
6adfdac9
...
@@ -490,6 +490,57 @@ namespace dlib
...
@@ -490,6 +490,57 @@ namespace dlib
- R.tl_corner() == point(p.x()-width/2, p.y()-height/2)
- R.tl_corner() == point(p.x()-width/2, p.y()-height/2)
!*/
!*/
// ----------------------------------------------------------------------------------------
const
drectangle
shrink_rect
(
const
drectangle
&
rect
,
double
num
);
/*!
ensures
- returns drectangle(rect.left()+num, rect.top()+num, rect.right()-num, rect.bottom()-num)
(i.e. shrinks the given drectangle by shrinking its border by num)
!*/
// ----------------------------------------------------------------------------------------
const
drectangle
grow_rect
(
const
drectangle
&
rect
,
double
num
);
/*!
ensures
- return shrink_rect(rect, -num)
(i.e. grows the given drectangle by expanding its border by num)
!*/
// ----------------------------------------------------------------------------------------
const
drectangle
shrink_rect
(
const
drectangle
&
rect
,
double
width
,
double
height
);
/*!
ensures
- returns drectangle(rect.left()+width, rect.top()+height, rect.right()-width, rect.bottom()-height)
(i.e. shrinks the given drectangle by shrinking its left and right borders by width
and its top and bottom borders by height. )
!*/
// ----------------------------------------------------------------------------------------
const
drectangle
grow_rect
(
const
drectangle
&
rect
,
double
width
,
double
height
);
/*!
ensures
- return shrink_rect(rect, -width, -height)
(i.e. grows the given drectangle by expanding its border)
!*/
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
}
}
...
...
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