shama/jmpress.js — Issue #39: Polar coords math problems
Author: luniki
Created: 2012-02-24 22:02:53+00:00
State: open

Using these step definitions:

step 1

step 2

step 3

step 4

step 4

causes bad CSS values:

translate(-50%,-50%) translate3d(700px,-4.2861222383783204e-14px,0px) rotateX(0deg) rotateY(0deg) rotateZ(0deg) scaleX(1) scaleY(1) scaleZ(1)

or

translate(-50%,-50%) translate3d(8.572244476756641e-14px,700px,0px) rotateX(0deg) rotateY(0deg) rotateZ(0deg) scaleX(1) scaleY(1) scaleZ(1)

resulting in steps without any transforms at all.

This is caused by the polar coords math:

Math.sin(sd.phi*Math.PI/180)
Math.cos(sd.phi*Math.PI/180)

Rounding the resulting numbers to a fixed precision (Math.floor(x * 10) / 10 or Number#toFixed) fixes these problems.