Skip to content or navigation


Write a 3D Software Engine from Scratch

Ever wondered what was involved in making a drawing or CAD program draw a basic line between two points?

Advertisement

We have wondered this too.

Over at Sitepoint, a site for web programming tutorials and education, a Javascript software tutorial explains the process of what is involved in drawing a line between two points. The math and nature of the algorithm is remarkably simple and eloquent.

You Will Never Get to the Wall

Remember that game where someone told you that if you walked half way to the wall in sequential steps, always just walking to the mid-point, you will never actually reach the wall. Ever.

Remember that? 

Like me you probably heard this as a kid and thought it didn’t make common sense but knowing basic math and division knew it make perfect mathematical logic. That is if you grasp infinity.

The Half Problem Ends

Here is how you program a computer to draw a line between two points. You define two points (point 0 and point 1). If the distance between the two points is less than 2 pixels you do nothing.

If the distance is more than 2 pixels you locate the mid-point (point 2). You change the color of this pixel. You repeat this basic algorithm recursively between point 0 and mid-point and between mid-point and point 1. Eventually you cut down the distances until you reach the first rule of this algorithm. And then the line is complete.

box

01 – To draw a line in 2D or 3D space within a CAD/3D program requires at least a basic algorithm. The trick to this algorithm is divide and conquer.

Over at Sitepoint they provide the coding examples for this in C#, TypeScript and Javascript. If you are a coder or are just curious hop on over and take a look at the code.

The Write a 3D Software Engine from Scratch article is written by David Rouset, developer evangelist at Microsoft. It was published a few days ago. We think it’s cool. And for Part 1 of this story you can click on that here.

Reader Comments

  1. Apollo Spiliotis liked this on Facebook.

  2. Write a 3D Software Engine from Scratch http://t.co/HG9kptT5PY

Comments are closed.

architosh

INSIDER Xpresso 

Monthly newsletter with a focus on emTech (AI, machine learning, AAD, AR, robotics, 3d printing, and smart cities) its impact on CAD professionals.)

Subscribe now — it’s free!.

INSIDER Xpresso keeps CAD industry professionals up-to-date on next-gen emerging technologies (emTech) that will revolutionize the worlds of AEC and manufacturing and design. As an Xpresso reader, you will hear from some of the most important voices inventing and using the very latest tech in areas such as AI, machine learning, algorithmic-aided design (AAD), AR, VR, MR, 3D printing, 3D computer vision, robotics, and SmartCities technologies.

Each issue arrives in your inbox on the first Sunday of the month. Issue #1 in your inbox March 3, 2019.

Sign-up for our monthly newsletter
architosh INSIDER Xpresso.

  • Architosh will never pass any of your information onto third parties.
  • For more information read our privacy policy.
  • It is easy to unsubscribe at any time. Follow the links in the newletter footer.

(Recommended. These infrequent sponsored emails help us to provide our Xpresso newsletter for free.)

 
INSIDER Membership

Read 3 free Feature or Analysis articles per month.

Or, subscribe now for unlimited full access to Architosh.