|
|
I am too new to grasp the function writing concept in POV.
the first step to matrix control is axis_rotation
#declare a=1.0;
#declare b=0.0;
#declare c=0.0;
#declare d=0.0;
#declare e=1.0;
#declare f=0.0;
#declare g=0.0;
#declare h=0.0;
#declare i=1.0;
#declare X=0.0;
#declare Y=0.0;
#declare Z=0.0;
#declare A=<a,b,c>;
#declare B=<d,e,f>;
#declare C=<g,h,i>;
#declare axis_rotation = function(r, z, y) {
// y * z * r //this only to see if pov accepts defined funtion parameters.
// it does.
// how to parse or tokenize a vector?
// C code is:
// r is radians (r,axis[3],point[3])
/*
double mag, s, c;
double x, y, z, xx, yy, zz, xy, yz, zx, xs, ys, zs, one_c;
s = sin(r);
c = cos(r);
mag = VLEN(axis);
// prevent divide by 0 error and normalize axis
if (mag == 0.0) mag = 1.0;
x = axis[0] / mag;
y = axis[1] / mag;
z = axis[2] / mag;
xx = x * x;
yy = y * y;
zz = z * z;
xy = x * y;
yz = y * z;
zx = z * x;
xs = x * s;
ys = y * s;
zs = z * s;
one_c = 1.0 - c;
x = point[0] * ((one_c * xx) + c);
y = point[0] * ((one_c * xy) - zs);
z = point[0] * ((one_c * zx) + ys);
x += point[1] * ((one_c * xy) + zs);
y += point[1] * ((one_c * yy) + c);
z += point[1] * ((one_c * yz) - xs);
x += point[2] * ((one_c * zx) - ys);
y += point[2] * ((one_c * yz) + xs);
z += point[2] * ((one_c * zz) + c);
point[0] = x;
point[1] = y;
point[2] = z;
*/
//and usage should be: vector = axis_rotation(r,A,B)
}
Post a reply to this message
|
|