コード例 #1
0
ファイル: stack.c プロジェクト: mattjakob/s3d
void s4_scale(Stack4 *s, Vector3 v)
{
  *s->mtop = m4_m4prod(*s->mtop, m4_scale(v.x, v.y, v.z));

  if (REL_EQ(v.x, 0.0) || REL_EQ(v.y,0.0) || REL_EQ(v.z,0.0)) 
    error("(s4_scale) unable to invert scale matrix");
  else
    *s->itop = m4_m4prod(m4_scale(1./v.x,1./v.y,1./v.z), *s->itop);
}
コード例 #2
0
ファイル: cylin.c プロジェクト: cheque/s3d
Prim *cylin_set(Prim *p, Vector3 bc, double h, double  r)
{
  Cylin *s = p->d;
  s->bc = bc; s->h = h; s->r = r;
  p->ti = p->td = m4_ident();
  p = cylin_transform(p, m4_scale(r,r,h), m4_scale(1/r,1/r,1/h)); 
  p = cylin_transform(p, m4_translate(bc.x,bc.y,bc.z), m4_translate(-bc.x,-bc.y,-bc.z));
  p->b = cylin_bbox(p);
  return p;
}
コード例 #3
0
ファイル: affine.c プロジェクト: mattjakob/s3d
Matrix4 m4_compxform(int k, char *t, Real **p, int j)
{
  int i;
  Matrix4 m = m4_ident();

  for (i = 0; i < k; i++) {
    switch (t[i]) {
    case G_TX: m = m4_m4prod(m4_translate(p[i][j], 0, 0), m); break;
    case G_TY: m = m4_m4prod(m4_translate(0, p[i][j], 0), m); break;
    case G_TZ: m = m4_m4prod(m4_translate(0, 0, p[i][j]), m); break;
    case G_RX: m = m4_m4prod(m4_rotate('x', p[i][j]), m); break;
    case G_RY: m = m4_m4prod(m4_rotate('y', p[i][j]), m); break;
    case G_RZ: m = m4_m4prod(m4_rotate('z', p[i][j]), m); break;
    case G_SX: m = m4_m4prod(m4_scale(p[i][j], 1, 1), m); break;
    case G_SY: m = m4_m4prod(m4_scale(1, p[i][j], 1), m); break;
    case G_SZ: m = m4_m4prod(m4_scale(1, 1, p[i][j]), m); break;
    default: break;
    }
  }
  return m;
}