Point Cloud Library (PCL) 1.13.1
Loading...
Searching...
No Matches
float3_operations.h
1/*
2 * Software License Agreement (BSD License)
3 *
4 * Point Cloud Library (PCL) - www.pointclouds.org
5 * Copyright (c) 2011, Willow Garage, Inc.
6 *
7 * All rights reserved.
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
11 * are met:
12 *
13 * * Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * * Redistributions in binary form must reproduce the above
16 * copyright notice, this list of conditions and the following
17 * disclaimer in the documentation and/or other materials provided
18 * with the distribution.
19 * * Neither the name of Willow Garage, Inc. nor the names of its
20 * contributors may be used to endorse or promote products derived
21 * from this software without specific prior written permission.
22 *
23 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
26 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
27 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
28 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
29 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
31 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
33 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34 * POSSIBILITY OF SUCH DAMAGE.
35 *
36 * Author: Raphael Favier, Technical University Eindhoven, (r.mysurname <aT> tue.nl)
37 *
38 */
39
40#include <iostream>
41
42namespace pcl
43{
44 namespace gpu
45 {
46 namespace kinfuLS
47 {
48 inline float
49 dot(const float3& v1, const float3& v2)
50 {
51 return v1.x * v2.x + v1.y*v2.y + v1.z*v2.z;
52 }
53
54 inline float3&
55 operator+=(float3& vec, const float& v)
56 {
57 vec.x += v; vec.y += v; vec.z += v; return vec;
58 }
59
60 inline float3&
61 operator+=(float3& vec, const float3& v)
62 {
63 vec.x += v.x; vec.y += v.y; vec.z += v.z; return vec;
64 }
65
66 inline float3
67 operator+(const float3& v1, const float3& v2)
68 {
69 return make_float3 (v1.x + v2.x, v1.y + v2.y, v1.z + v2.z);
70 }
71
72 inline float3&
73 operator*=(float3& vec, const float& v)
74 {
75 vec.x *= v; vec.y *= v; vec.z *= v; return vec;
76 }
77
78 inline float3&
79 operator-=(float3& vec, const float& v)
80 {
81 vec.x -= v; vec.y -= v; vec.z -= v; return vec;
82 }
83
84 inline float3&
85 operator-=(float3& vec, const float3& v)
86 {
87 vec.x -= v.x; vec.y -= v.y; vec.z -= v.z; return vec;
88 }
89
90 inline float3
91 operator-(const float3& v1, const float3& v2)
92 {
93 return make_float3 (v1.x - v2.x, v1.y - v2.y, v1.z - v2.z);
94 }
95
96 inline float3
97 operator-(const float3& v1)
98 {
99 return make_float3 (-v1.x, -v1.y, -v1.z);
100 }
101
102 inline float3
103 operator-(float3& v1)
104 {
105 v1.x = -v1.x; v1.y = -v1.y; v1.z = -v1.z; return v1;
106 }
107
108 inline float3
109 operator*(const float3& v1, const float& v)
110 {
111 return make_float3 (v1.x * v, v1.y * v, v1.z * v);
112 }
113
114 inline float
115 norm(const float3& v)
116 {
117 return sqrt (dot (v, v));
118 }
119
120 inline std::ostream&
121 operator << (std::ostream& os, const float3& v1)
122 {
123 os << "[" << v1.x << ", " << v1.y << ", " << v1.z<< "]";
124 return (os);
125 }
126
127 /*inline float3
128 normalized(const float3& v)
129 {
130 return v * rsqrt(dot(v, v));
131 }*/
132
133 inline float3
134 cross(const float3& v1, const float3& v2)
135 {
136 return make_float3 (v1.y * v2.z - v1.z * v2.y, v1.z * v2.x - v1.x * v2.z, v1.x * v2.y - v1.y * v2.x);
137 }
138 }
139 }
140}
std::ostream & operator<<(std::ostream &os, const float3 &v1)
float3 & operator-=(float3 &vec, const float &v)
float3 operator-(const float3 &v1, const float3 &v2)
float3 operator+(const float3 &v1, const float3 &v2)
float norm(const float3 &v)
float3 & operator*=(float3 &vec, const float &v)
float3 & operator+=(float3 &vec, const float &v)
float3 operator*(const float3 &v1, const float &v)
float3 cross(const float3 &v1, const float3 &v2)
float dot(const float3 &v1, const float3 &v2)