/* test22.c */
#include <stdio.h>
#include "sslib.h"
int main(void)
{
double cr, cro, ct, cto, cz, czo;
double deg, dx, dxo, dy, dyo, dz, dzo;
double pr, pro, pe, peo, pp, ppo;
double phai, psai, r, rad, ro, t, thet, to, trot;
double x, xm, xo, y, ym, yo, z, zo;
int error;
printf("< 角度変換 (deg <-> rad) >\n");
deg = 30.0;
dtor(deg, &rad);
printf(" Degree to Radian Transformation\n");
printf(" deg = %10.6f\n", deg);
printf(" rad = %19.16f\n", rad);
printf(" Exact = %19.16f\n\n", M_PI / 6.0);
rad = M_PI;
rtod(rad, °);
printf(" Radian to Degree Transformation\n");
printf(" rad = %18.14f\n", rad);
printf(" deg = %18.14f\n", deg);
printf(" Exact = %18.14f\n\n", 180.0);
printf("< 二次元座標変換 (デカルト座標 <-> 極座標(角度単位:deg) >\n");
xo = 2.0;
yo = 2.0;
error = dtop2(xo, yo, &r, &t);
printf(" Cartesian to Poler coordinate\n");
printf(" x = %8.3f y = %8.3f\n", xo, yo);
printf(" r = %8.3f t = %8.3f\n", r, t);
printf(" error = %5d\n\n", error);
error = ptod2(r, t, &x, &y);
printf(" Poler to Cartesian coordinate\n");
printf(" r = %8.3f t = %8.3f\n", r, t);
printf(" x = %8.3f y = %8.3f\n", x, y);
printf(" error = %5d\n\n", error);
printf("< 二次元平行移動 (極座標系角度単位:deg)>\n");
xo = 2.0;
yo = 2.0;
xm = 0.5;
ym = 0.5;
error = dmov2(xo, yo, xm, ym, &x, &y);
printf(" Parallel move (cartesian coordinate)\n");
printf(" xo = %8.3f yo = %8.3f dx = %8.3f dy = %8.3f\n", xo, yo, xm, ym);
printf(" x = %8.3f y = %8.3f\n", x, y);
printf(" error = %5d\n\n", error);
ro = 1.0;
to = 30.0;
error = pmov2(ro, to, xm, ym, &r, &t);
printf(" Parallel move (Poler coordinate)\n");
printf(" ro = %8.3f to = %8.3f xm = %8.3f ym = %8.3f\n", ro, to, xm, ym);
printf(" r = %8.3f t = %8.3f\n", r, t);
printf(" error = %5d\n\n", error);
printf("< 2次元回転移動 (極座標系角度単位:deg)>\n");
xo = 2.0;
yo = 2.0;
ro = 1.0;
to = 30.0;
trot = 15.0;
t = 45.0;
error = drot2(xo, yo, t, &x, &y);
printf(" Rotation (Cartesian coordinate)\n");
printf(" xo = %8.3f yo = %8.3f rot = %8.3f(deg)\n", xo, yo, t);
printf(" x = %8.3f y = %8.3f\n", x, y);
printf(" error = %5d\n", error);
error = prot2(ro, to, trot, &r, &t);
printf(" Rotation (Poler coordinate)\n");
printf(" ro = %8.3f to = %8.3f trot = %8.3f(deg)\n", ro, to, trot);
printf(" r = %8.3f t = %8.3f\n", r, t);
printf(" error = %5d\n\n", error);
printf("< 三次元座標変換 (デカルト座標 <-> 円柱座標 <-> 極座標 角度単位:deg)\n");
printf(" Exchange Coordinate ( 3-dimansion )\n");
printf(" Decurtes <-> Cylindorical\n");
dx = dy = 2.0;
dz = 3.0;
printf(" x = %10.4f y = %10.4f z = %10.4f\n", dx, dy, dz);
dtoc3(dx, dy, dz, &cr, &ct, &cz);
printf(" cr = %10.4f ct = %10.4f cz = %10.4f\n", cr, ct, cz);
ctod3(cr, ct, cz, &dx, &dy, &dz);
printf(" x = %10.4f y = %10.4f z = %10.4f\n\n", dx, dy, dz);
printf(" Decurtes <-> Poler\n");
printf(" x = %10.4f y = %10.4f z = %10.4f\n", dx, dy, dz);
dtop3(dx, dy, dz, &pr, &pe, &pp);
printf(" pr = %10.4f pe = %10.4f pp = %10.4f\n", pr, pe, pp);
ptod3(pr, pe, pp, &dz, &dy, &dz);
printf(" x = %10.4f y = %10.4f z = %10.4f\n\n", dx, dy, dz);
printf(" Poler <-> Cylindorical\n");
cr = 2.0;
ct = 30.0;
cz = 1.0;
printf(" cr = %10.4f ct = %10.4f cz = %10.4f\n", cr, ct, cz);
ctop3(cr, ct, cz, &pr, &pe, &pp);
printf(" pr = %10.4f pe = %10.4f pp = %10.4f\n", pr, pe, pp);
ptoc3(pr, pe, pp, &cr, &ct, &cz);
printf(" cr = %10.4f ct = %10.4f cz = %10.4f\n\n", cr, ct, cz);
printf("< 三次元平行移動 (角度単位:deg)\n");
xo = dx = 1.0;
yo = dy = 1.0;
zo = dz = 1.0;
error = dpmov3(xo, yo, zo, dx, dy, dz, &x, &y, &z);
printf("Pallarel Move in 3-Dimensional coordinate\n");
printf(" Decartes Coordinate\n");
printf(" xo = %6.4f yo = %6.4f zo = %6.4f\n", xo, yo, zo);
printf(" dx = %6.4f dy = %6.4f dz = %6.4f\n", dx, dy, dz);
printf(" x = %6.4f y = %6.4f z = %6.4f\n", x, y, z);
printf(" Error = %5d\n\n", error);
cro = 1.0;
cto = 45.0;
czo = 1.0;
error = cpmov3(cro, cto, czo, dx, dy, dz, &cr, &ct, &cz);
printf(" Cylindorical Coordinate\n");
printf(" cro = %6.3f cto = %6.3f czo = %6.3f\n", cro, cto, czo);
printf(" dx = %6.3f dy = %6.3f dz = %6.3f\n", dx, dy, dz);
printf(" cr = %6.3f ct = %6.3f cz = %6.3f\n", cr, ct, cz);
printf(" Error = %5d\n\n", error);
pro = 1.0;
peo = 45.0;
ppo = 45.0;
error = ppmov3(pro, peo, ppo, dx, dy, dz, &pr, &pe, &pp);
printf(" Poler Coordinate\n");
printf(" pro = %6.3f peo = %6.3f ppo = %6.3f\n", pro, peo, ppo);
printf(" dx = %6.3f dy = %6.3f dz = %6.3f\n", dx, dy, dz);
printf(" pr = %6.3f pe = %6.3f pp = %6.3f\n", pr, pe, pp);
printf(" Error = %5d\n\n", error);
printf("< 三次元回転移動 (角度単位:deg)\n");
dxo = sqrt(6.0) / 4.0;
dyo = sqrt(2.0) / 4.0;
dzo = 1.0;
phai = 30.0;
thet = psai = 45.0;
error = drot3(dxo, dyo, dzo, phai, thet, psai, &dx, &dy, &dz);
printf(" Rotate Move in 3-Diensional Coordinate\n");
printf(" Cartesian Coordinate\n");
printf(" dxo = %7.4f dyo = %7.4f dzo = %7.4f\n", dxo, dyo, dzo);
printf(" phai = %7.3f thet = %7.3f psai = %7.3f\n", phai, thet, psai);
printf(" dx = %7.4f dy = %7.4f dz = %7.4f\n", dx, dy, dz);
printf(" Exact= %7.4f %7.4f %7.4f\n", 1.0, 0.0, M_SQRT_2);
printf(" Error= %5d\n\n", error);
cro = 1.0;
cto = 90.0;
czo = sqrt(3.0);
phai = thet = 90.0;
psai = -90.0;
error = crot3(cro, cto, czo, phai, thet, psai, &cr, &ct, &cz);
printf(" Cylindorical Coordinate\n");
printf(" cro = %7.4f cto = %7.4f czo = %7.4f\n", cro, cto, czo);
printf(" phai = %7.3f thet = %7.3f psai = %7.3f\n", phai, thet, psai);
printf(" cr = %7.4f ct = %7.4f cz = %7.4f\n", cr, ct, cz);
printf(" Exact= %7.4f %7.4f %7.4f\n", 2.0, 150.0, 0.0);
printf(" Error= %5d\n\n", error);
pro = 1.0;
peo = ppo = 0.0;
phai = thet = psai = 90.0;
error = prot3(pro, peo, ppo, phai, thet, psai, &pr, &pe, &pp);
printf(" Polar Coordinate\n");
printf(" pro = %7.4f peo = %7.4f ppo = %7.4f\n", pro, peo, ppo);
printf(" phai = %7.3f thet = %7.3f psai = %7.3f\n", phai, thet, psai);
printf(" pr = %7.4f pe = %7.4f pp = %7.4f\n", pr, pe, pp);
printf(" Exact= %7.4f %7.4f %7.4f\n", 1.0, 0.0, 90.0);
printf(" Error= %5d\n\n", error);
return 1;
}
|