VictorCMiraldo/hs-fragem

Polyphony formula is wrong

Closed this issue · 7 comments

@irisyupingren , the formula in https://github.com/VictorCMiraldo/hs-fragem/wiki/Polyphony seems wrong.

Consider we have two voices that maintain a pitch of 1, over a time interval of 1. For theta = 90,
the makes half a cube of side 1. Hence, the volume should be 0.5, yet, the formula on the wiki
will return 0.

Parameters: a0 = 1 ; a1 = 1 ; b0 = 1 ; b1 = 1 ; t = 1 ; theta = 90

Hmm, the formula will actually return 0.5 * 1 * 1 * 1 corresponding to (1/2) * sin90 * a0 * b0...

Not every term is with the integral variable x.
In this special case, the first term remains constant.
If it's necessary I can move the first term out of the bracket.
But if there's no further questions on this special case, feel free to close the issue :)

I don't think so! The a0 * b0 term will be canceled out.

1/2 * sin2 theta * (
      (a0*b0 + z1^2/2 * a0 * db + z1^2/2 * b0 * da + z1^3/3 * da * db) 
   -  (a0*b0 + z0^2/2 * a0 * db + z0^2/2 * b0 * da + z0^3/3 * da * db)
 )

The a0 * b0 term cancels out. da = a1 - a0 and db = b1 - b0. Both are 0 in this case.
Hence, the whole parenthesis evaluates to 0.

1/2 * sin2 theta * 0 == 0

Now, the formula in the wiki does not parse. There is one unclosed parenthesis. Maybe we
are reading different formulas.

Oh my bad my bad, the first term should be outside the bracket indeed.

Should be
1/2 * sin2 theta * a0b0 + 1/2 *sin2 theta (....rest of the terms evaluated at z1 and z0)

(The area is coming along but turns out to be much more complicated than the volume!)

Just updated the wiki for Volume. Should be the right one this time.
Area should be done before 3 today.
Or feel free to leave me a TODO in the Maths.hs to fill out the equations.

Still doesn't work!

A simple case is theta = 90, a0 = a1 = 4 , b0 = b1 = 4, which makes a simple triangle
with depth 1.

For z0 = 0, z1=1, we expect the formula to give 4^2/2 == 8, which it does.
But if we change z1 to 2 instead, the result should be 16 but it remains 8.

No panic... Sorry it was the unfortunate slip of hand on the first term. There should be an x after sin theta a0 b0. Just updated the formula.

(The Area is also there now. Lots of efforts spent on simplifying already but still quite monstrous isn't it? I'm trying to interpret it better. Maybe a discussion point for the next time!)