Toggle navigation
Toggle navigation
This project
Loading...
Sign in
尹诚
/
Mapbox-iOS-SDK
·
Commits
Go to a project
GitLab
Go to dashboard
Project
Activity
Files
Commits
Pipelines
0
Builds
0
Graphs
Milestones
Issues
0
Merge Requests
0
Members
Labels
Wiki
Forks
Network
Create a new issue
Download as
Email Patches
Plain Diff
Browse Files
Authored by
Thomas Rasch
13 years ago
Commit
a7b7390dc3ee8f310f4198005eb2c7c2f8647d8a
1 parent
c2d1ce4b
o Added RMProjectedRectUnion and RMProjectedRectIsZero to RMFoundation
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
38 additions
and
0 deletions
MapView/Map/RMFoundation.c
MapView/Map/RMFoundation.h
MapView/Map/RMFoundation.c
View file @
a7b7390
...
...
@@ -127,6 +127,38 @@ RMProjectedRect RMProjectedRectZero()
return
RMProjectedRectMake
(
0
.
0
,
0
.
0
,
0
.
0
,
0
.
0
);
}
bool
RMProjectedRectIsZero
(
RMProjectedRect
rect
)
{
return
(
rect
.
origin
.
x
==
0
.
0
)
&&
(
rect
.
origin
.
y
==
0
.
0
)
&&
(
rect
.
size
.
width
==
0
.
0
)
&&
(
rect
.
size
.
height
==
0
.
0
);
}
#if !defined (RMMIN)
#define RMMIN(a,b) ((a) < (b) ? (a) : (b))
#endif
#if !defined (RMMAX)
#define RMMAX(a,b) ((a) > (b) ? (a) : (b))
#endif
RMProjectedRect
RMProjectedRectUnion
(
RMProjectedRect
rect1
,
RMProjectedRect
rect2
)
{
bool
rect1IsZero
=
RMProjectedRectIsZero
(
rect1
);
bool
rect2IsZero
=
RMProjectedRectIsZero
(
rect2
);
if
(
rect1IsZero
)
return
(
rect2IsZero
?
RMProjectedRectZero
()
:
rect2
);
if
(
rect2IsZero
)
return
rect1
;
double
minX
=
RMMIN
(
rect1
.
origin
.
x
,
rect2
.
origin
.
x
);
double
minY
=
RMMIN
(
rect1
.
origin
.
y
,
rect2
.
origin
.
y
);
double
maxX
=
RMMAX
(
rect1
.
origin
.
x
+
rect1
.
size
.
width
,
rect2
.
origin
.
x
+
rect2
.
size
.
width
);
double
maxY
=
RMMAX
(
rect1
.
origin
.
y
+
rect2
.
size
.
height
,
rect2
.
origin
.
y
+
rect2
.
size
.
height
);
return
RMProjectedRectMake
(
minX
,
minY
,
maxX
-
minX
,
maxY
-
minY
);
}
double
RMEuclideanDistanceBetweenProjectedPoints
(
RMProjectedPoint
point1
,
RMProjectedPoint
point2
)
{
double
xd
=
point2
.
x
-
point1
.
x
;
...
...
MapView/Map/RMFoundation.h
View file @
a7b7390
...
...
@@ -69,16 +69,22 @@ RMProjectedRect RMTranslateProjectedRectBy(RMProjectedRect rect, RMProjectedSiz
/// \brief The function checks whether two passed projected points are equal.
bool
RMProjectedPointEqualToProjectedPoint
(
RMProjectedPoint
point1
,
RMProjectedPoint
point2
);
/// \brief The function returs true if the passed rects intersect each other.
bool
RMProjectedRectIntersectsProjectedRect
(
RMProjectedRect
rect1
,
RMProjectedRect
rect2
);
/// \brief The function returns true if rect1 contains rect2
bool
RMProjectedRectContainsProjectedRect
(
RMProjectedRect
rect1
,
RMProjectedRect
rect2
);
// Union of two rectangles
RMProjectedRect
RMProjectedRectUnion
(
RMProjectedRect
rect1
,
RMProjectedRect
rect2
);
RMProjectedPoint
RMProjectedPointMake
(
double
x
,
double
y
);
RMProjectedRect
RMProjectedRectMake
(
double
x
,
double
y
,
double
width
,
double
height
);
RMProjectedSize
RMProjectedSizeMake
(
double
width
,
double
heigth
);
RMProjectedRect
RMProjectedRectZero
();
bool
RMProjectedRectIsZero
(
RMProjectedRect
rect
);
double
RMEuclideanDistanceBetweenProjectedPoints
(
RMProjectedPoint
point1
,
RMProjectedPoint
point2
);
...
...
Please
register
or
login
to post a comment