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:
- 17:3c9672c6e532
- Parent:
- 16:64cd7bc094f9
- Child:
- 18:8256546a3cbf
--- a/Rasturizer/Rasturizer.cpp Sun Mar 31 18:05:01 2019 +0000
+++ b/Rasturizer/Rasturizer.cpp Sun Mar 31 18:10:18 2019 +0000
@@ -5,7 +5,7 @@
Rasturizer::Rasturizer(){
- /*double tempPoints[4][3] = {{43, 2.5, 30}, {43, 2.5, 200}, {43, -2.5, 200}, {43, -2.5, 30}};
+ /*float tempPoints[4][3] = {{43, 2.5, 30}, {43, 2.5, 200}, {43, -2.5, 200}, {43, -2.5, 30}};
for(int vertex = 0; vertex < 8; vertex++){
for(int axis = 0; axis < 3; axis++){
edgePoints[vertex][axis] = tempPoints[vertex][axis];
@@ -20,15 +20,15 @@
fov = 50;
}
-double Rasturizer::xTo2D(double x, double z){
+float Rasturizer::xTo2D(float x, float z){
return x * (fov/z) + 42;
}
-double Rasturizer::yTo2D(double y, double z){
+float Rasturizer::yTo2D(float y, float z){
return y * (fov/z) + 21;
}
-void Rasturizer::drawHorizon(double angle){
+void Rasturizer::drawHorizon(float angle){
lcd.drawLine(0,
21-rint(angle*50),
84,
@@ -41,14 +41,14 @@
drawFace(edge, angle);*/
}
-void Rasturizer::drawFace(Face face, double angle){
- double points[4][3];
+void Rasturizer::drawFace(Face face, float angle){
+ float 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];
+ float y = points[vertex][1];
+ float x = points[vertex][0];
points[vertex][0] = x*cos(angle)-y*sin(angle);
points[vertex][1] = y*cos(angle)+x*sin(angle);
@@ -60,9 +60,9 @@
int diffX2 = xTo2D(points[2][0], points[2][2])-xTo2D(points[3][0], points[3][2]);
int diffY2 = yTo2D(points[2][1], points[2][2])-yTo2D(points[3][1], points[3][2]);
- double step = (double)diffY2/(double)diffX2;
- double stepSmall1 = (double)diffX1/(double)diffX2;
- double stepSmall2 = (double)diffY1/(double)diffX2;
+ float step = (float)diffY2/(float)diffX2;
+ float stepSmall1 = (float)diffX1/(float)diffX2;
+ float stepSmall2 = (float)diffY1/(float)diffX2;
for(int s = 0; s< abs(diffX2); s++){
if(diffX2 > 0){