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:
- 11:2cd6341136ca
- Parent:
- 10:07a23afd5088
- Child:
- 12:b69657862610
diff -r 07a23afd5088 -r 2cd6341136ca Rasturizer/Rasturizer.cpp
--- a/Rasturizer/Rasturizer.cpp Tue Mar 19 12:12:52 2019 +0000
+++ b/Rasturizer/Rasturizer.cpp Sun Mar 24 12:31:38 2019 +0000
@@ -8,15 +8,37 @@
lcd.init();
}
-void Rasturizer::drawFace(Face face){
+void Rasturizer::drawHorizon(double angle){
+ lcd.drawLine(0,
+ 21,
+ 84,
+ 21,
+ 1);/*
+ double floorPoints[14][3] = {{-120,5, 5}, {-120,0, 1000}, {-80,5, 5}, {-80,0, 1000}, {-40,5, 5}, {-40,0, 1000}, {0,5, 5}, {0,0, 1000}, {40,5, 5}, {40,0, 1000}, {80,5, 5}, {80,0, 1000}, {120,5, 5}, {120,0, 1000}};//{-10,20, 10}, {-10,0, 100}, {0,20, 10}, {0,0, 100}, {10,20, 10}, {10,0, 100}, {20,20, 10}, {20,0, 100},{30,20, 10}, {30,0, 100}};
+ for(int i = 0; i < 14; i += 2){
+ lcd.drawLine(rint(floorPoints[i][0]*(40/floorPoints[i][2]))+42,
+ rint(floorPoints[i][1]*(40/floorPoints[i][2]))+21,
+ rint(floorPoints[i+1][0]*(40/floorPoints[i+1][2]))+42,
+ rint(floorPoints[i+1][1]*(40/floorPoints[i+1][2]))+21,
+ 1);
+ }*/
+}
+
+void Rasturizer::drawFace(Face face, double angle){
double points[4][3];
for(int vertex = 0; vertex < 4; vertex++){
for(int axis = 0; axis < 3; axis++){
points[vertex][axis] = face.getVertexValue(vertex, axis);
}
+ double y = points[vertex][1];
+ double x = points[vertex][0];
+
+ points[vertex][0] = x*cos(angle)-y*sin(angle);
+ points[vertex][1] = y*cos(angle)+x*sin(angle);
}
- if (points[0][2] > 20 || points[1][2] > 20 || points[2][2] > 20|| points[3][2] > 20){
+
+ if (points[0][2] > 10 || points[1][2] > 10 || points[2][2] > 10|| points[3][2] > 10){
int diffX1 = points[0][0]-points[1][0];
int diffY1 = points[0][1]-points[1][1];
@@ -29,7 +51,6 @@
for(int s = 0; s<= abs(diffX2)-1; s++){
lcd.drawLine(rint((points[0][0]-stepSmall1*s)*(40/points[0][2]))+42, rint((points[0][1]-stepSmall2*s)*(40/points[0][2]))+21,rint((points[3][0]+s)*(40/points[3][2]))+42, rint((points[3][1]+step*s)*(40/points[3][2]))+21, 0);
- lcd.drawLine(rint((points[0][0]-stepSmall1*s-1)*(40/points[0][2])+42), rint((points[0][1]-stepSmall2*s)*(40/points[0][2])+21),rint((points[3][0]+s+1)*(40/points[3][2]))+42, rint((points[3][1]+step*s)*(40/points[3][2]))+21, 0);
}
for (int i = 0; i < 3; i++){
@@ -49,6 +70,10 @@
}
}
+void Rasturizer::print(const char *text){
+ lcd.printString(text, 0, 0);
+}
+
void Rasturizer::clear(){
lcd.clear();
}