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
0a101d9cbc715954273a4b63da3a85dee8939842
1 parent
42848309
o Added a few helper methods to RMFoundation
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
48 additions
and
4 deletions
MapView/Map/RMFoundation.c
MapView/Map/RMFoundation.h
MapView/Map/RMFoundation.c
View file @
0a101d9
...
...
@@ -27,6 +27,7 @@
#import "RMFoundation.h"
#import <math.h>
#import <stdio.h>
bool
RMProjectedPointEqualToProjectedPoint
(
RMProjectedPoint
point1
,
RMProjectedPoint
point2
)
{
...
...
@@ -64,6 +65,24 @@ bool RMProjectedRectContainsProjectedRect(RMProjectedRect rect1, RMProjectedRect
return
((
minX2
>=
minX1
&&
maxX2
<=
maxX1
)
&&
(
minY2
>=
minY1
&&
maxY2
<=
maxY1
));
}
bool
RMProjectedRectContainsProjectedPoint
(
RMProjectedRect
rect
,
RMProjectedPoint
point
)
{
if
(
rect
.
origin
.
x
>
point
.
x
||
rect
.
origin
.
x
+
rect
.
size
.
width
<
point
.
x
||
rect
.
origin
.
y
>
point
.
y
||
rect
.
origin
.
y
+
rect
.
size
.
height
<
point
.
y
)
{
return
false
;
}
return
true
;
}
bool
RMProjectedSizeContainsProjectedSize
(
RMProjectedSize
size1
,
RMProjectedSize
size2
)
{
return
(
size1
.
width
>=
size2
.
width
&&
size1
.
height
>=
size2
.
height
);
}
RMProjectedPoint
RMScaleProjectedPointAboutPoint
(
RMProjectedPoint
point
,
float
factor
,
RMProjectedPoint
pivot
)
{
point
.
x
=
(
point
.
x
-
pivot
.
x
)
*
factor
+
pivot
.
x
;
...
...
@@ -159,6 +178,7 @@ RMProjectedRect RMProjectedRectUnion(RMProjectedRect rect1, RMProjectedRect rect
return
RMProjectedRectMake
(
minX
,
minY
,
maxX
-
minX
,
maxY
-
minY
);
}
// apparently, this doesn't work well with coordinates on a sphere, but it might be appropriate for a quick estimation
double
RMEuclideanDistanceBetweenProjectedPoints
(
RMProjectedPoint
point1
,
RMProjectedPoint
point2
)
{
double
xd
=
point2
.
x
-
point1
.
x
;
...
...
@@ -166,3 +186,15 @@ double RMEuclideanDistanceBetweenProjectedPoints(RMProjectedPoint point1, RMProj
return
sqrt
(
xd
*
xd
+
yd
*
yd
);
}
#pragma mark -
void
RMLogProjectedPoint
(
RMProjectedPoint
point
)
{
printf
(
"ProjectedPoint at (%.0f,%.0f)
\n
"
,
point
.
x
,
point
.
y
);
}
void
RMLogProjectedRect
(
RMProjectedRect
rect
)
{
printf
(
"ProjectedRect at (%.0f,%.0f), size (%.0f,%.0f)
\n
"
,
rect
.
origin
.
x
,
rect
.
origin
.
y
,
rect
.
size
.
width
,
rect
.
size
.
height
);
}
...
...
MapView/Map/RMFoundation.h
View file @
0a101d9
...
...
@@ -62,19 +62,24 @@ typedef struct {
}
RMSphericalTrapezium
;
#endif
#pragma mark -
RMProjectedPoint
RMScaleProjectedPointAboutPoint
(
RMProjectedPoint
point
,
float
factor
,
RMProjectedPoint
pivot
);
RMProjectedRect
RMScaleProjectedRectAboutPoint
(
RMProjectedRect
rect
,
float
factor
,
RMProjectedPoint
pivot
);
RMProjectedPoint
RMTranslateProjectedPointBy
(
RMProjectedPoint
point
,
RMProjectedSize
delta
);
RMProjectedRect
RMTranslateProjectedRectBy
(
RMProjectedRect
rect
,
RMProjectedSize
delta
);
/// \brief The function checks whether two passed projected points are equal.
#pragma mark -
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
);
bool
RMProjectedRectContainsProjectedPoint
(
RMProjectedRect
rect
,
RMProjectedPoint
point
);
bool
RMProjectedSizeContainsProjectedSize
(
RMProjectedSize
size1
,
RMProjectedSize
size2
);
#pragma mark -
// Union of two rectangles
RMProjectedRect
RMProjectedRectUnion
(
RMProjectedRect
rect1
,
RMProjectedRect
rect2
);
...
...
@@ -86,6 +91,13 @@ RMProjectedSize RMProjectedSizeMake(double width, double heigth);
RMProjectedRect
RMProjectedRectZero
();
bool
RMProjectedRectIsZero
(
RMProjectedRect
rect
);
#pragma mark -
double
RMEuclideanDistanceBetweenProjectedPoints
(
RMProjectedPoint
point1
,
RMProjectedPoint
point2
);
#pragma mark -
void
RMLogProjectedPoint
(
RMProjectedPoint
point
);
void
RMLogProjectedRect
(
RMProjectedRect
rect
);
#endif
...
...
Please
register
or
login
to post a comment