Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
Diff: Rasturizer/Rasturizer.cpp
- Revision:
- 19:ec4cb22accb0
- Parent:
- 18:8256546a3cbf
- Child:
- 20:3ca430241df0
--- a/Rasturizer/Rasturizer.cpp Sun Mar 31 22:05:54 2019 +0000
+++ b/Rasturizer/Rasturizer.cpp Mon Apr 01 14:43:18 2019 +0000
@@ -54,7 +54,7 @@
points[vertex][1] = y*cos(angle)+x*sin(angle);
}
- if ((points[0][2] > 12 || points[1][2] > 12 || points[2][2] > 12|| points[3][2] > 12) && face.getVisible()){
+ if (checkOnScreen(points) && face.getVisible()){
int diffX1 = xTo2D(points[0][0], points[0][2])-xTo2D(points[1][0], points[1][2]);
int diffY1 = yTo2D(points[0][1], points[0][2])-yTo2D(points[1][1], points[1][2]);
int diffX2 = xTo2D(points[2][0], points[2][2])-xTo2D(points[3][0], points[3][2]);
@@ -97,6 +97,19 @@
}
}
+bool Rasturizer::checkOnScreen(float (&points)[4][3]){
+ if (points[0][2] < 10 || points[1][2] < 10 || points[2][2] < 10 || points[3][2] < 10){
+ return false;
+ }
+ else if ((xTo2D(points[0][0], points[0][2]) < 0 || xTo2D(points[0][0], points[0][2]) > 84)
+ && (xTo2D(points[1][0], points[1][2]) < 0 || xTo2D(points[1][0], points[1][2]) > 84)
+ && (xTo2D(points[2][0], points[2][2]) < 0 || xTo2D(points[2][0], points[2][2]) > 84)
+ && (xTo2D(points[3][0], points[3][2]) < 0 || xTo2D(points[3][0], points[3][2]) > 84)){
+ return false;
+ }
+ return true;
+}
+
void Rasturizer::print(const char *text, int x, int y){
lcd.printString(text, x, y);
}