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

SCM Repository

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

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

Parent Directory Parent Directory | Revision Log Revision Log

Revision 3349 - (download) (as text) (annotate)
Tue Oct 27 15:16:36 2015 UTC (5 years, 11 months ago) by jhr
File size: 4681 byte(s)
making copyrights consistent for all code in the repository
/*! \file cl-inline-image.h
 * \author Lamont Samuels

 * This code is part of the Diderot Project (http://diderot-language.cs.uchicago.edu)
 * COPYRIGHT (c) 2015 The University of Chicago
 * All rights reserved.

#  include "cl-types.h"
#  include "cl-inline-matrix.h"

/***** 1D Image functions *****/

// check if pos is inside the img, assuming that we have a border of width s.
inline bool Inside1f (float pos, __global Diderot_image1D_t *img, int s)
    return ((s-1 < pos) && (pos < (img->size[0] - s)));

inline float ToImageSpace1f ( __global Diderot_image1D_t *img, float pos)
    return img->s * pos + img->t;

/***** 2D Image functions *****/

// check if pos is inside the img, assuming that we have a border of width s.
inline bool Inside2f (float2 posArg, __global Diderot_image2D_t *img, int s)
    return ((s-1 < posArg.s0) && (posArg.s0 < (img->size[0] - s))
        &&  (s-1 < posArg.s1) && (posArg.s1 < (img->size[1] - s)));

inline float2 ToImageSpace2f (__global Diderot_image2D_t *img, float2 p)
    return (float2)(dot(img->w2i[0], p), dot(img->w2i[1], p)) + img->tVec;

inline float2 ToWorldSpace2f (__global Diderot_image2D_t *img, float2 g)
    return (float2)(
        dot(img->w2iT[0], g),
        dot(img->w2iT[1], g));

inline void ToWorldSpace2x2f ( Diderot_Mat2x2_t dst, __global Diderot_image2D_t *img,  Diderot_Mat2x2_t src)
    /* Diderot_Mat2x2_t tmp;
    mulMat2x2Mat2x2f (tmp, img->w2iT, src);
    mulMat2x2Mat2x2f (dst, tmp, img->w2i); */ 
    Diderot_Mat2x2_t tmp;
    tmp[0] = (float2)(
        dot(img->w2iT[0], (float2)(src[0].s0, src[1].s0)),
        dot(img->w2iT[0], (float2)(src[0].s1, src[1].s1)));
    tmp[1] = (float2)(
        dot(img->w2iT[1], (float2)(src[0].s0, src[1].s0)),
        dot(img->w2iT[1], (float2)(src[0].s1, src[1].s1)));
    dst[0] = (float2)(
        dot(tmp[0], (float2)(img->w2i[0].s0, img->w2i[1].s0)),
        dot(tmp[0], (float2)(img->w2i[0].s1, img->w2i[1].s1)));
    dst[1] = (float2)(
        dot(tmp[1], (float2)(img->w2i[0].s0, img->w2i[1].s0)),
        dot(tmp[1], (float2)(img->w2i[0].s1, img->w2i[1].s1)));


/***** 3D Image functions *****/

// check if pos is inside the img, assuming that we have a border of width s.
inline bool Inside3f (float3 posArg, __global Diderot_image3D_t *img, int s)
    return ((s-1 < posArg.s0) && (posArg.s0 < (img->size[0] - s))
        &&  (s-1 < posArg.s1) && (posArg.s1 < (img->size[1] - s))
        &&  (s-1 < posArg.s2) && (posArg.s2 < (img->size[2] - s)));

inline float3 ToImageSpace3f (__global Diderot_image3D_t *img, float3 p)
    return VEC3(dot(img->w2i[0], p), dot(img->w2i[1], p), dot(img->w2i[2], p)) + img->tVec;

inline float3 ToWorldSpace3f (__global Diderot_image3D_t *img, float3 g)
    return VEC3(
        dot(img->w2iT[0], g),
        dot(img->w2iT[1], g),
        dot(img->w2iT[2], g));

inline void ToWorldSpace3x3f ( Diderot_Mat3x3_t dst, __global Diderot_image3D_t *img,  Diderot_Mat3x3_t src)
    Diderot_Mat3x3_t tmp;
    tmp[0] = VEC3(
          dot(img->w2iT[0], VEC3(src[0].s0, src[1].s0, src[2].s0)),
          dot(img->w2iT[0], VEC3(src[0].s1, src[1].s1, src[2].s1)),
          dot(img->w2iT[0], VEC3(src[0].s2, src[1].s2, src[2].s2)));
    tmp[1] = VEC3(
          dot(img->w2iT[1], VEC3(src[0].s0, src[1].s0, src[2].s0)),
          dot(img->w2iT[1], VEC3(src[0].s1, src[1].s1, src[2].s1)),
          dot(img->w2iT[1], VEC3(src[0].s2, src[1].s2, src[2].s2)));
    tmp[2] = VEC3(
          dot(img->w2iT[2], VEC3(src[0].s0, src[1].s0, src[2].s0)),
          dot(img->w2iT[2], VEC3(src[0].s1, src[1].s1, src[2].s1)),
          dot(img->w2iT[2], VEC3(src[0].s2, src[1].s2, src[2].s2)));
    dst[0] = VEC3(
          dot(tmp[0], VEC3(img->w2i[0].s0, img->w2i[1].s0, img->w2i[2].s0)),
          dot(tmp[0], VEC3(img->w2i[0].s1, img->w2i[1].s1, img->w2i[2].s1)),
          dot(tmp[0], VEC3(img->w2i[0].s2, img->w2i[1].s2, img->w2i[2].s2)));
    dst[1] = VEC3(
          dot(tmp[1], VEC3(img->w2i[0].s0, img->w2i[1].s0, img->w2i[2].s0)),
          dot(tmp[1], VEC3(img->w2i[0].s1, img->w2i[1].s1, img->w2i[2].s1)),
          dot(tmp[1], VEC3(img->w2i[0].s2, img->w2i[1].s2, img->w2i[2].s2)));
    dst[2] = VEC3(
          dot(tmp[2], VEC3(img->w2i[0].s0, img->w2i[1].s0, img->w2i[2].s0)),
          dot(tmp[2], VEC3(img->w2i[0].s1, img->w2i[1].s1, img->w2i[2].s1)),
          dot(tmp[2], VEC3(img->w2i[0].s2, img->w2i[1].s2, img->w2i[2].s2)));



ViewVC Help
Powered by ViewVC 1.0.0