Home My Page Projects Code Snippets Project Openings diderot
Summary Activity Tracker Tasks SCM

SCM Repository

[diderot] Diff of /branches/pure-cfg/src/include/Diderot/inline-image.h
ViewVC logotype

Diff of /branches/pure-cfg/src/include/Diderot/inline-image.h

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 990, Tue Apr 26 23:15:12 2011 UTC revision 991, Wed Apr 27 04:53:08 2011 UTC
# Line 38  Line 38 
38    
39  STATIC_INLINE float ToImageSpace1f (Diderot_image1D_t *img, float pos)  STATIC_INLINE float ToImageSpace1f (Diderot_image1D_t *img, float pos)
40  {  {
41      vec2f_t p = __extension__ vec2f(pos, 1.0f);      return img->s * pos + img->t;
   
     return dot2f(img->mInv[0].v, p);  
42  }  }
43    
44    
45  /***** 2D Image functions *****/  /***** 2D Image functions *****/
46    
47  // check if pos is inside the img, assuming that we have a border of width s.  // check if pos is inside the img, assuming that we have a border of width s.
# Line 58  Line 57 
57          &&  (s-1 < pos.r[1]) && (pos.r[1] < (img->size[1] - s)));          &&  (s-1 < pos.r[1]) && (pos.r[1] < (img->size[1] - s)));
58  }  }
59    
60  STATIC_INLINE vec2f_t ToImageSpace2f (Diderot_image2D_t *img, vec2f_t posArg)  STATIC_INLINE vec2f_t ToImageSpace2f (Diderot_image2D_t *img, vec2f_t p)
61  {  {
62      vec3f_t p = __extension__ vec3f(      return vec2f(dot2f(img->w2i[0].v, p), dot2f(img->w2i[1].v, p)) + img->tVec;
         ((union2f_t)posArg).r[0],  
         ((union2f_t)posArg).r[1],  
         1.0f);  
   
     return vec2f(  
         dot3f(img->mInv[0].v, p),  
         dot3f(img->mInv[1].v, p));  
63  }  }
64    
65  STATIC_INLINE vec2f_t ToWorldSpace2f (Diderot_image2D_t *img, vec2f_t gradArg)  STATIC_INLINE vec2f_t ToWorldSpace2f (Diderot_image2D_t *img, vec2f_t g)
66  {  {
     vec3f_t g = __extension__ vec3f(  
         ((union2f_t)gradArg).r[0],  
         ((union2f_t)gradArg).r[1],  
         0.0f);  
   
67      return vec2f(      return vec2f(
68          dot3f(img->mInvT[0].v, g),          dot2f(img->w2iT[0].v, g),
69          dot3f(img->mInvT[1].v, g));          dot2f(img->w2iT[1].v, g));
70  }  }
71    
72  STATIC_INLINE void ToWorldSpace2x2f (Diderot_Mat2x2_t dst, Diderot_image2D_t *img, Diderot_Mat2x2_t src)  STATIC_INLINE void ToWorldSpace2x2f (Diderot_Mat2x2_t dst, Diderot_image2D_t *img, Diderot_Mat2x2_t src)
73  {  {
74      copy2x2f(dst, src);  // FIXME: only works for identity transforms      Diderot_Mat2x2_t tmp;
75        mulMat2x2Mat2x2f (tmp, img->w2iT, src);
76        mulMat2x2Mat2x2f (dst, tmp, img->w2i);
77  }  }
78    
79    
80  /***** 3D Image functions *****/  /***** 3D Image functions *****/
81    
82  // check if pos is inside the img, assuming that we have a border of width s.  // check if pos is inside the img, assuming that we have a border of width s.
# Line 103  Line 93 
93          &&  (s-1 < pos.r[2]) && (pos.r[2] < (img->size[2] - s)));          &&  (s-1 < pos.r[2]) && (pos.r[2] < (img->size[2] - s)));
94  }  }
95    
96  STATIC_INLINE vec3f_t ToImageSpace3f (Diderot_image3D_t *img, vec3f_t posArg)  STATIC_INLINE vec3f_t ToImageSpace3f (Diderot_image3D_t *img, vec3f_t p)
97  {  {
98      vec4f_t p = __extension__ vec4f(      return vec3f(dot3f(img->w2i[0].v, p), dot3f(img->w2i[1].v, p), dot3f(img->w2i[2].v, p)) + img->tVec;
         ((union3f_t)posArg).r[0],  
         ((union3f_t)posArg).r[1],  
         ((union3f_t)posArg).r[2],  
         1.0f);  
   
     return vec3f(  
         dot4f(img->mInv[0].v, p),  
         dot4f(img->mInv[1].v, p),  
         dot4f(img->mInv[2].v, p));  
99  }  }
100    
101  STATIC_INLINE vec3f_t ToWorldSpace3f (Diderot_image3D_t *img, vec3f_t gradArg)  STATIC_INLINE vec3f_t ToWorldSpace3f (Diderot_image3D_t *img, vec3f_t g)
102  {  {
     vec4f_t g = __extension__ vec4f(  
         ((union3f_t)gradArg).r[0],  
         ((union3f_t)gradArg).r[1],  
         ((union3f_t)gradArg).r[2],  
         0.0f);  
   
103      return vec3f(      return vec3f(
104          dot4f(img->mInvT[0].v, g),          dot3f(img->w2iT[0].v, g),
105          dot4f(img->mInvT[1].v, g),          dot3f(img->w2iT[1].v, g),
106          dot4f(img->mInvT[2].v, g));          dot3f(img->w2iT[2].v, g));
107  }  }
108    
109  STATIC_INLINE void ToWorldSpace3x3f (Diderot_Mat3x3_t dst, Diderot_image3D_t *img, Diderot_Mat3x3_t src)  STATIC_INLINE void ToWorldSpace3x3f (Diderot_Mat3x3_t dst, Diderot_image3D_t *img, Diderot_Mat3x3_t src)
110  {  {
111      copy3x3f(dst, src);  // FIXME: only works for identity transforms      Diderot_Mat3x3_t tmp;
112        mulMat3x3Mat3x3f (tmp, img->w2iT, src);
113        mulMat3x3Mat3x3f (dst, tmp, img->w2i);
114  }  }
115    
116  #endif /* !_DIDEROT_INLINE_IMAGE_H_ */  #endif /* !_DIDEROT_INLINE_IMAGE_H_ */

Legend:
Removed from v.990  
changed lines
  Added in v.991

root@smlnj-gforge.cs.uchicago.edu
ViewVC Help
Powered by ViewVC 1.0.0