|
|
For those of you that want to be able to do matrix calculations within POV-Ray,
I have made a library that can do some of that.
It can be found here:
https://github.com/t-o-k/POV-Ray-matrices
(NB: Some of the descriptions and examples are not finished yet.)
Below are some examples with this library that may be relevant to this thread.
--
Tor Olav
http://subcube.com
https://github.com/t-o-k
// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7
#version 3.7; // Should also work in version 3.8
global_settings { assumed_gamma 1.0 }
#include "matrices.inc"
// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7
#declare No_Change_Transform = transform { }
#declare Rotate_Transform = transform { rotate 60*x }
#declare Shear_Transform =
transform {
matrix <
1, 1, 0,
0, 1, 0,
0, 0, 1,
0, 0, 0
>
}
#declare Translate_Transform = transform { translate <3, 1, 2> }
#declare Composite_Transform =
transform {
No_Change_Transform
Rotate_Transform
Shear_Transform
Translate_Transform
}
#debug "\nNo Change Transform:\n"
M_Print(M_FromTransform(No_Change_Transform))
#debug "\nRotate Transform:\n"
M_Print(M_FromTransform(Rotate_Transform))
#debug "\nShear Transform:\n"
M_Print(M_FromTransform(Shear_Transform))
#debug "\nTranslate Transform:\n"
M_Print(M_FromTransform(Translate_Transform))
#debug "\nComposite Transform:\n"
M_Print(M_FromTransform(Composite_Transform))
#debug "\n\n"
// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7
#declare No_Change_Matrix = M_Identity(4);
#declare Rotate_Matrix = M_Rotate3D_AroundX(radians(60));
#declare Shear_Matrix =
array[4][4] {
{ 1.0, 1.0, 0.0, 0.0 },
{ 0.0, 1.0, 0.0, 0.0 },
{ 0.0, 0.0, 1.0, 0.0 },
{ 0.0, 0.0, 0.0, 1.0 }
}
;
#declare Translate_Matrix = M_Translate3D(<3, 1, 2>);
#declare Composite_Matrix =
M_Mult(
M_Mult(
M_Mult(
No_Change_Matrix,
Rotate_Matrix
),
Shear_Matrix
),
Translate_Matrix
)
;
#debug "\nNo Change Matrix:\n"
M_Print(No_Change_Matrix)
#debug "\nRotate Matrix:\n"
M_Print(Rotate_Matrix)
#debug "\nShear Matrix:\n"
M_Print(Shear_Matrix)
#debug "\nTranslate Matrix:\n"
M_Print(Translate_Matrix)
#debug "\nComposite Matrix:\n"
M_Print(Composite_Matrix)
// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7
#debug "\n"
#error "No error, just finished"
// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7
Post a reply to this message
|
|