If you have seen the Popup Book tutorial for Cinema 4D by Robert Leger and want to know how to solve the problem in the mathematical way read below.
Here is the Robert’s tutorial:
This is my result obtained with my solution:
I know that the following symbolism is not simple to read because I chose one that is ready to be transferred to COFFEE code and simple to write in this blog. In the project file you find a pdf that contains the solution using the mathematic notation.
First of all, I want to fix my axes to take advantage of symmetry.
The origin is fixed on the point O. When the book is closing the two pages rotate together alpha degrees. I choose alpha as variable for the animation.
Now I want to have free choose of points: A and B.
The point A’ is symmetric respect to the ZY-plane by point A.
The point B stays on the plane x=0.
Now, with the book opened (alpha=0), I set the point A and B that I call _A and _B. In this manner I have set the distances OA,OB,AB that must be the same at any angle.
Generalizing a point P is defined through its variables as P (x, z, y) so:
A(alpha=0)=_A=(X_A, Z_A, 0)
B(alpha=0)=_B=(0, Z_B, Y_B)
It is obvious that Y_A=X_B=0
Then X_A, Z_A, Z_B, Y_B are all set.
I’m searching a solution for points A and B:
A=A(alpha)=(XA,,ZA,YA)=(X_A*cos(alpha), Z_A, X_A*sin(alpha))
A is solved. Note that XA^2+YA^2=X_A^2
B=(0, ZB, YB)
Now I’m searching a solution for B.
The equations:
1) The point B describes an arc of a circle with radius R equal to length OB.
ZB^2+YB^2=R^2 (note that also R^2=Z_B^2+Y_B^2)
2) The distance AB= constant
at any alpha:
AB^2=(XA-XB)^2+(ZA-ZB)^2+(YA-YB)^2
at alpha=0:
AB^2=(X_A-X_B)^2+(Z_A-Z_B)^2+(Y_A-Y_B)^2
=>
(remember that Y_A=X_B=0)
XA^2+(Z_A-ZB)^2+(YA-YB)^2=X_A^2+(Z_A-Z_B)^2+Y_B^2
XA^2+Z_A^2-2*Z_A*ZB+ZB^2+YA^2-2*YA*YB+YB^2=X_A^2+Z_A^2-2*Z_A*Z_B+Z_B^2+Y_B^2
after some steps, I found:
YA*YB+Z_A*ZB=Z_A*Z_B
For YA=0 (that is the same condition alpha=0) we have ZB=Z_B that is the correct value.
When alpha is fixed (YA fixed) this is an equation of a line (r). For YA>0:
YB=(Z_A*Z_B-Z_A*ZB)/YA
The intersection of the two equations gives two solutions. I”ll choose the solution with YB>0.
Now let’s go on with the calculations.
For semplicity: K=Z_A*Z_B
Intersect of:
1) YA*YB+Z_A*ZB=K => ZB=(K-YA*YB)/Z_A
2) ZB^2+YB^2=R^2
Raplacing ZB of equation 1) in equation 2):
((K-YA*YB)/Z_A)^2+YB^2=R^2 =>
(YA^2+Z_A^2)*YB^2-2*K*YA*YB+(K^2-R^2*Z_A^2)=0 quadratic equation
The positive solution is:
YB=[K*YA+Z_A*sqrt(YA^2*R^2+Z_A^2*R^2-K^2)]/(YA^2+Z_A^2)
Now I can Calculate ZB:
ZB=(K-YA*YB)/Z_A
The problem is solved!
Now I can write a COFFEE node for the algorithm:
main()
{
var Z_B,Y_B,X_A,Z_A,Z_B2,Y_B2,Z_A2,YA2,alpha,K,K2,R2;
X_A=Input1;
Z_A=Input2;
Z_B=Input3;
Y_B=Input4;
alpha=Input5;
Z_A2=Z_A*Z_A;
Z_B2=Z_B*Z_B;
Y_B2=Y_B*Y_B;
YA=X_A*sin(alpha);
YA2=YA*YA;
XA=X_A*cos(alpha);
R2=Z_B2+Y_B2;
K=Z_A*Z_B;
K2=K*K;
YB=(K*YA+Z_A*sqrt(YA2*R2+Z_A2*R2-K2))/(YA2+Z_A2);
ZB=(K-YA*YB)/Z_A;
}
I hope this tutorial can be useful also just like a mathematic exercise.
Download the project file:
(new version for R20 and above + 4 pages project)
In the project file you find a pdf that contains the solution using the mathematic notation.
Hi Giannni, I think you might have melted my brain but thank you. This has come at just the right time for a project I am working on, but I need to turn on to the next page which also needs to be a popup, is there a way of duplicating the pages and then driving the close with the opening of the new page. Forgive me I am still finding my way with all this. Any help or advice would be gratefully received. thank you T 😉
Hi Tracey,
I’m glad for your words.
I think that all is possible… but it also true that sometimes we don’t see the way, impossible to see. 😀
However I think that I can add an Xpresso slider for right page control. I’m going to manage the project file in the next 1-2 days. At that point I think that add a few pairs of pages is possible and also driving the close with the next opening.
Pingback: Behind Dog Chow Ad | N11
Thanks for mentioning my work that solves the problem in analytical way.
I’m glad you find this helpful for your work.
Hi there, nice stuff! May I just ask you for reuploading the file? The link doesn’t work. Thank you in advance.
Thank you Jan,
I’ll do it as soon as I can.
Gianni
Hi. Can you reupload the file..?
The problem is that hotfile.com closed because of illegal content.
Thanks.
Yes, I know.
For now I’m sending the file to everyone that asks me.
Stay tuned for the file in your mailbox. 😉
Bye
Ok. Got it. Thank you. 😉
Perfect! 🙂
The link the file is broken!
Hi Bruno,
I know that, l need to modify the article.
In any case, as I said above I’m sending the file to everyone that asks me.
I ‘ll send you a file to your email address if you want. 🙂
hi can you send the file to me too?
Sure! 😉
Hey Can I have the file also. Thanks
Sure! 😉
Hello friend!
Excellent their work, perfect pop up! Exactly what I’ve been trying to make some time! You can send me this file in C4D? Sincerely, Daniel Librelon. danlibrelon@yahoo.com.br
Thanks in advance!
Olá amigo!
Excelente seu trabalho, pop up perfeito! Exatamente o que eu venho tentando fazer a algum tempo! Você pode me enviar esse arquivo em c4d? Atenciosamente, Daniel Librelon. danlibrelon@yahoo.com.br
Desde já agradeço!
Thank you Daniel,
I’ll send you the file in two minutes.
Ok Thanks!
Friend! Thank you, I needed to understand how the movements of a pop up works, just seeing even understand! You helped me more! Thanks a lot!
Daniel Librelon.
Amigo! Muito obrigado, eu precisava entender como funciona os movimentos de um pop up, só vendo mesmo para entender! Você me ajudou de mais! Obrigado mesmo!
Daniel Librelon.
You are welcome Daniel.
Cheers,
Gianni
thanks for this amazing work gianni ..could u share the file with me??thanks in advance!!!
Thanks!
Ok, I will.
You blow my mind with your thinking process… any chance to get the file?
Thanks!
You find the link at the end of the article.
In any case:
https://www.dropbox.com/s/gnj1ngfelip6ad1/PopUpBook_Mathematic_Solution.rar
Has anyone ported that C.O.F.F.E.E. script over to Python?
Hi Byron,
I will do it soon for sure!
I’m curious why the script was needed. Could those equations not be solved with the nodes?
Yes, you can do it using nodes. The COFFEE or Python node simplifies the setup.
Another question! Thanks for your patience. I think I followed along properly and the rig opens and closes like it should. However, it seems that I’m getting some stretching somewhere. If I check the distance between the points, I’m getting some fluctuation and I see some visible stretching. Does yours do that?
Scratch that previous comment! I was following Robert’s tutorial. Since I’m on R20 I can’t get your COFFEE version to work.