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 1592, Tue Nov 1 09:41:35 2011 UTC revision 1593, Tue Nov 1 12:28:30 2011 UTC
# Line 31  Line 31 
31    
32  // 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.
33  //  //
34  STATIC_INLINE bool Inside1f (float pos, Diderot_image1D_t *img, int s)  STATIC_INLINE bool Inside1 (float pos, Diderot_image1D_t *img, int s)
35  {  {
36      return ((s-1 < pos) && (pos < (img->size[0] - s)));      return ((s-1 < pos) && (pos < (img->size[0] - s)));
37  }  }
38    
39  STATIC_INLINE float ToImageSpace1f (Diderot_image1D_t *img, float pos)  STATIC_INLINE float ToImageSpace1 (Diderot_image1D_t *img, float pos)
40  {  {
41      return img->s * pos + img->t;      return img->s * pos + img->t;
42  }  }
# Line 46  Line 46 
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.
48  //  //
49  STATIC_INLINE bool Inside2f (vec2f_t posArg, Diderot_image2D_t *img, int s)  STATIC_INLINE bool Inside2 (Diderot_vec2_t posArg, Diderot_image2D_t *img, int s)
50  {  {
51  // NOTE: there might be a vectorized way to do this compare!  // NOTE: there might be a vectorized way to do this compare!
52  // cvtps2pi -- converts vector of floats to vector of int32_t values  // cvtps2pi -- converts vector of floats to vector of int32_t values
53    
54      union2f_t pos;      Diderot_union2_t pos;
55      pos.v = posArg;      pos.v = posArg;
56      return ((s-1 < pos.r[0]) && (pos.r[0] < (img->size[0] - s))      return ((s-1 < pos.r[0]) && (pos.r[0] < (img->size[0] - s))
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 p)  STATIC_INLINE Diderot_vec2_t ToImageSpace2 (Diderot_image2D_t *img, Diderot_vec2_t p)
61  {  {
62      return vec2f(dot2f(img->w2i[0].v, p), dot2f(img->w2i[1].v, p)) + img->tVec;      return vec2(dot2(img->w2i[0].v, p), dot2(img->w2i[1].v, p)) + img->tVec;
63  }  }
64    
65  STATIC_INLINE vec2f_t ToWorldSpace2f (Diderot_image2D_t *img, vec2f_t g)  STATIC_INLINE Diderot_vec2_t ToWorldSpace2 (Diderot_image2D_t *img, Diderot_vec2_t g)
66  {  {
67      return vec2f(      return vec2(
68          dot2f(img->w2iT[0].v, g),          dot2(img->w2iT[0].v, g),
69          dot2f(img->w2iT[1].v, g));          dot2(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 ToWorldSpace2x2 (Diderot_Mat2x2_t dst, Diderot_image2D_t *img, Diderot_Mat2x2_t src)
73  {  {
74      Diderot_Mat2x2_t tmp;      Diderot_Mat2x2_t tmp;
75      mulMat2x2Mat2x2f (tmp, img->w2iT, src);      mulMat2x2Mat2x2 (tmp, img->w2iT, src);
76      mulMat2x2Mat2x2f (dst, tmp, img->w2i);      mulMat2x2Mat2x2 (dst, tmp, img->w2i);
77  }  }
78    
79    
# Line 81  Line 81 
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.
83  //  //
84  STATIC_INLINE bool Inside3f (vec3f_t posArg, Diderot_image3D_t *img, int s)  STATIC_INLINE bool Inside3 (Diderot_vec3_t posArg, Diderot_image3D_t *img, int s)
85  {  {
86  // NOTE: there might be a vectorized way to do this compare!  // NOTE: there might be a vectorized way to do this compare!
87  // cvtps2pi -- converts vector of floats to vector of int32_t values  // cvtps2pi -- converts vector of floats to vector of int32_t values
88    
89      union3f_t pos;      Diderot_union3_t pos;
90      pos.v = posArg;      pos.v = posArg;
91      return ((s-1 < pos.r[0]) && (pos.r[0] < (img->size[0] - s))      return ((s-1 < pos.r[0]) && (pos.r[0] < (img->size[0] - s))
92          &&  (s-1 < pos.r[1]) && (pos.r[1] < (img->size[1] - s))          &&  (s-1 < pos.r[1]) && (pos.r[1] < (img->size[1] - s))
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 p)  STATIC_INLINE Diderot_vec3_t ToImageSpace3 (Diderot_image3D_t *img, Diderot_vec3_t p)
97  {  {
98      return vec3f(dot3f(img->w2i[0].v, p), dot3f(img->w2i[1].v, p), dot3f(img->w2i[2].v, p)) + img->tVec;      return vec3(dot3(img->w2i[0].v, p), dot3(img->w2i[1].v, p), dot3(img->w2i[2].v, p)) + img->tVec;
99  }  }
100    
101  STATIC_INLINE vec3f_t ToWorldSpace3f (Diderot_image3D_t *img, vec3f_t g)  STATIC_INLINE Diderot_vec3_t ToWorldSpace3 (Diderot_image3D_t *img, Diderot_vec3_t g)
102  {  {
103      return vec3f(      return vec3(
104          dot3f(img->w2iT[0].v, g),          dot3(img->w2iT[0].v, g),
105          dot3f(img->w2iT[1].v, g),          dot3(img->w2iT[1].v, g),
106          dot3f(img->w2iT[2].v, g));          dot3(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 ToWorldSpace3x3 (Diderot_Mat3x3_t dst, Diderot_image3D_t *img, Diderot_Mat3x3_t src)
110  {  {
111      Diderot_Mat3x3_t tmp;      Diderot_Mat3x3_t tmp;
112      mulMat3x3Mat3x3f (tmp, img->w2iT, src);      mulMat3x3Mat3x3 (tmp, img->w2iT, src);
113      mulMat3x3Mat3x3f (dst, tmp, img->w2i);      mulMat3x3Mat3x3 (dst, tmp, img->w2i);
114  }  }
115    
116  #endif /* !_DIDEROT_INLINE_IMAGE_H_ */  #endif /* !_DIDEROT_INLINE_IMAGE_H_ */

Legend:
Removed from v.1592  
changed lines
  Added in v.1593

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