summaryrefslogtreecommitdiff
path: root/src/transform.cu
blob: 1f4405e155441508d32029a024d64a84961efd3f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
//-*-c-*-

#include "linalg.h"
#include "rotate.h"

extern "C"
{

/* Translate the points `a` by the vector `v` */
__global__ void
translate(int nthreads, float3 *a, float3 v)
{
    int id = blockIdx.x*blockDim.x + threadIdx.x;

    if (id >= nthreads)
	return;

    a[id] += v;
}

/* Rotate the points `a` through an angle `phi` counter-clockwise about the
   axis `axis` (when looking towards +infinity). */
__global__ void
rotate(int nthreads, float3 *a, float phi, float3 axis)
{
    int id = blockIdx.x*blockDim.x + threadIdx.x;

    if (id >= nthreads)
	return;

    a[id] = rotate(a[id], phi, axis);
}

/* Rotate the points `a` through an angle `phi` counter-clockwise
   (when looking towards +infinity along `axis`) about the axis defined
   by the point `point` and the vector `axis` . */
__global__ void
rotate_around_point(int nthreads, float3 *a, float phi, float3 axis,
		    float3 point)
{
    int id = blockIdx.x*blockDim.x + threadIdx.x;

    if (id >= nthreads)
	return;

    a[id] -= point;
    a[id] = rotate(a[id], phi, axis);
    a[id] += point;
}

} // extern "c"