Skip to content

garsaud/Pure-JS-rotating-cube

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 

Repository files navigation

Rotating Cube

Spinning cube in wireframe, with a text-based viewport. This is vanilla JS, and everything is done using homemade math functions. Move your mouse pointer to rotate the cube in the direction you want.

See it here

I use some tricks to approximate the sinus/cosinus function:

function sine(x) { x = x%6.28; if (x < -3.14159265) x += 6.28318531; else if (x > 3.14159265) x -= 6.28318531; if (x < 0) return 1.27323954 * x + 0.405284735 * x * x; return 1.27323954 * x - 0.405284735 * x * x; } function cosse(x) { return sine(x-1.57); } function skrt(x) { var a = 1, b = x; while(abse(a-b)>5) { a = (a+b)/2; b = x/a; } return a; } function abse(x) { return (x > 0) ? x : -x; }

About

A 3D cube in wireframe drawn as text, rotating using math functions only

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages