Skip to content

Instantly share code, notes, and snippets.

@smcl
Created January 25, 2016 08:57
Show Gist options
  • Save smcl/e901d989a520bb8b012e to your computer and use it in GitHub Desktop.
Save smcl/e901d989a520bb8b012e to your computer and use it in GitHub Desktop.
void drawProjectedLine(point3D_type from, point3D_type to) {
from.z += CAM_F;
to.z += CAM_F;
int x1_2D = CAM_X + (int)(((double)from.x / (double)from.z) * CAM_F);
int y1_2D = CAM_Y + (int)(((double)from.y / (double)from.z) * CAM_F);
int x2_2D = CAM_X + (int)(((double)to.x / (double)to.z) * CAM_F);
int y2_2D = CAM_Y + (int)(((double)to.y / (double)to.z) * CAM_F);
/* take projected positions and draw on screen */
display.drawLine(x1_2D, y1_2D, x2_2D, y2_2D, WHITE);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment