Perception Tool Kit (PTK) API Guide
point.h
Go to the documentation of this file.
1 /*
2  *
3  * Copyright (c) 2018 Texas Instruments Incorporated
4  *
5  * All rights reserved not granted herein.
6  *
7  * Limited License.
8  *
9  * Texas Instruments Incorporated grants a world-wide, royalty-free, non-exclusive
10  * license under copyrights and patents it now or hereafter owns or controls to make,
11  * have made, use, import, offer to sell and sell ("Utilize") this software subject to the
12  * terms herein. With respect to the foregoing patent license, such license is granted
13  * solely to the extent that any such patent is necessary to Utilize the software alone.
14  * The patent license shall not apply to any combinations which include this software,
15  * other than combinations with devices manufactured by or for TI ("TI Devices").
16  * No hardware patent is licensed hereunder.
17  *
18  * Redistributions must preserve existing copyright notices and reproduce this license
19  * (including the above copyright notice and the disclaimer and (if applicable) source
20  * code license limitations below) in the documentation and/or other materials provided
21  * with the distribution
22  *
23  * Redistribution and use in binary form, without modification, are permitted provided
24  * that the following conditions are met:
25  *
26  * * No reverse engineering, decompilation, or disassembly of this software is
27  * permitted with respect to any software provided in binary form.
28  *
29  * * any redistribution and use are licensed by TI for use only with TI Devices.
30  *
31  * * Nothing shall obligate TI to provide you with source code for the software
32  * licensed and provided to you in object code.
33  *
34  * If software source code is provided to you, modification and redistribution of the
35  * source code are permitted provided that the following conditions are met:
36  *
37  * * any redistribution and use of the source code, including any resulting derivative
38  * works, are licensed by TI for use only with TI Devices.
39  *
40  * * any redistribution and use of any object code compiled from the source code
41  * and any resulting derivative works, are licensed by TI for use only with TI Devices.
42  *
43  * Neither the name of Texas Instruments Incorporated nor the names of its suppliers
44  *
45  * may be used to endorse or promote products derived from this software without
46  * specific prior written permission.
47  *
48  * DISCLAIMER.
49  *
50  * THIS SOFTWARE IS PROVIDED BY TI AND TI'S LICENSORS "AS IS" AND ANY EXPRESS
51  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
52  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
53  * IN NO EVENT SHALL TI AND TI'S LICENSORS BE LIABLE FOR ANY DIRECT, INDIRECT,
54  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
55  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
56  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
57  * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
58  * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
59  * OF THE POSSIBILITY OF SUCH DAMAGE.
60  *
61  */
62 #pragma once
63 #ifndef PTK_POINT_H
64 #define PTK_POINT_H
65 
71 #include <stdint.h>
72 
74 
110 #ifdef __cplusplus
111 extern "C" {
112 #endif
113 
119 typedef union
120 {
122  float w;
123 
127  uint32_t f;
128 
130 
136 typedef struct
137 {
139  float x;
140 
142  float y;
143 
145  float z;
146 
149 
150 } PTK_Vector;
151 
158 
164 typedef union
165 {
167  double w;
168 
172  uint32_t f;
173 
175 
187 typedef struct
188 {
190  double x;
191 
193  double y;
194 
196  double z;
197 
200 
201 } PTK_Vector_d;
202 
209 
210 
216 typedef struct
217 {
219  float x;
220 
222  float y;
223 
224 } PTK_2D_Vector;
225 
227 
228 
244 void PTK_Point_set(PTK_Point *dst, float x, float y, float z);
245 
258 void PTK_Vector_add(PTK_Vector *dst, const PTK_Vector *src1, const PTK_Vector *src2);
259 
272 void PTK_Vector_subtract(PTK_Vector *dst, const PTK_Vector *src1, const PTK_Vector *src2);
273 
286 void PTK_Vector_scale(PTK_Vector *dst, const PTK_Vector *src, float scale);
287 
299 void PTK_Point_transform(PTK_Point *dst, const PTK_Point *src, const PTK_RigidTransform *M);
300 
313 float PTK_Vector_dot2(const PTK_Vector *p1, const PTK_Vector *p2);
314 
327 float PTK_Vector_dot3(const PTK_Vector *p1, const PTK_Vector *p2);
328 
344 float PTK_Vector_dot4(const PTK_Vector *p1, const PTK_Vector *p2);
345 
360 void PTK_Vector_computeCrossProduct(PTK_Vector *__restrict dst, const PTK_Vector *__restrict a, const PTK_Vector *__restrict b);
361 
372 float PTK_Vector_computeNorm(const PTK_Vector *v);
373 
385 float PTK_Vector_normalize(PTK_Vector *__restrict dst, const PTK_Vector *__restrict in);
386 
396 void PTK_Point_tag(PTK_Point *pt, uint32_t tag);
397 
407 void PTK_Point_untag(PTK_Point *pt, uint32_t tag);
408 
424 uint32_t PTK_Point_isTagged(PTK_Point *pt, uint32_t tag);
425 
441 void PTK_Point_d_set(PTK_Point_d *dst, double x, double y, double z);
442 
455 void PTK_Vector_d_add(PTK_Vector_d *dst, PTK_Vector_d *src1, PTK_Vector_d *src2);
456 
470 
483 void PTK_Vector_d_scale(PTK_Vector_d *dst, PTK_Vector_d *src, double scale);
484 
497 
510 double PTK_Vector_d_dot2(const PTK_Vector_d *p1, const PTK_Vector_d *p2);
511 
524 double PTK_Vector_d_dot3(const PTK_Vector_d *p1, const PTK_Vector_d *p2);
525 
541 double PTK_Vector_d_dot4(const PTK_Vector_d *p1, const PTK_Vector_d *p2);
542 
552 void PTK_Point_d_tag(PTK_Point_d *pt, uint32_t tag);
553 
563 void PTK_Point_d_untag(PTK_Point_d *pt, uint32_t tag);
564 
580 uint32_t PTK_Point_d_isTagged(PTK_Point_d *pt, uint32_t tag);
581 
582 #ifdef __cplusplus
583 }
584 #endif
585 
586 #endif
PTK_Vector_d PTK_Point_d
Definition of a double precision Point.
Definition: point.h:208
float y
Definition: point.h:142
float x
Definition: point.h:219
double PTK_Vector_d_dot2(const PTK_Vector_d *p1, const PTK_Vector_d *p2)
Compute the dot product of the two given vectors in 2D, given by r = ax*bx + ay*by.
void PTK_Vector_subtract(PTK_Vector *dst, const PTK_Vector *src1, const PTK_Vector *src2)
Perform component-wise subtraction, subtracting src2 from src1 and writing the result to dst...
float z
Definition: point.h:145
PTK_Vector_Meta meta
Definition: point.h:148
uint32_t f
Definition: point.h:172
void PTK_Vector_d_scale(PTK_Vector_d *dst, PTK_Vector_d *src, double scale)
Perform component-wise scaling of the given PTK Vector and store the result at dst.
Definition of doube precision vector meta data.
Definition: point.h:164
double PTK_Vector_d_dot4(const PTK_Vector_d *p1, const PTK_Vector_d *p2)
Compute the dot product of the two given vectors in 3D, given by r = ax*bx + ay*by + az*bz + aw*bw...
double x
Definition: point.h:190
PTK_2D_Vector PTK_2D_Point
Definition: point.h:226
void PTK_Point_d_transform(PTK_Point_d *dst, PTK_Point_d *src, const PTK_RigidTransform_d *M)
Perform a rigid transformation on the given point, d = (Mr*s) + Mt.
float PTK_Vector_computeNorm(const PTK_Vector *v)
Computes the L2 norm of the given vector, given by v = sqrt(vx*vx + vy*vy + vz*vz).
Definition of a double precision Vector.
Definition: point.h:187
void PTK_Point_tag(PTK_Point *pt, uint32_t tag)
This sets tag bits for the given point.
uint32_t PTK_Point_isTagged(PTK_Point *pt, uint32_t tag)
This checks if all of the bits set in tag are also set in the tag for the given PTK_Point. Additional bits may be set, but none may be missing from the given mask.
uint32_t PTK_Point_d_isTagged(PTK_Point_d *pt, uint32_t tag)
This checks if all of the bits set in tag are also set in the tag for the given PTK_Point. Additional bits may be set, but none may be missing from the given mask.
uint32_t f
Definition: point.h:127
double y
Definition: point.h:193
void PTK_Point_d_set(PTK_Point_d *dst, double x, double y, double z)
Updates all three components stored within the given PTK_Point to match those given as arguments...
Definition of vector meta data.
Definition: point.h:119
float PTK_Vector_normalize(PTK_Vector *__restrict dst, const PTK_Vector *__restrict in)
Normalizes the given input vector and writes to an output vector.
void PTK_Point_untag(PTK_Point *pt, uint32_t tag)
This removes tag bits for the given point.
Rigid Transform Matrix (single precision).
Definition: rigidTransform.h:85
Rigid Transform Matrix (double precision).
Definition: rigidTransform.h:118
float w
Definition: point.h:122
Definition of a point.
Definition: point.h:136
double PTK_Vector_d_dot3(const PTK_Vector_d *p1, const PTK_Vector_d *p2)
Compute the dot product of the two given vectors in 3D, given by r = ax*bx + ay*by + az*bz...
void PTK_Point_transform(PTK_Point *dst, const PTK_Point *src, const PTK_RigidTransform *M)
Perform a rigid transformation on the given point, d = (Mr*s) + Mt.
PTK_Vector_d_Meta meta
Definition: point.h:199
Declaration of structures and functions for rigid transforms.
void PTK_Vector_computeCrossProduct(PTK_Vector *__restrict dst, const PTK_Vector *__restrict a, const PTK_Vector *__restrict b)
Computes the cross product of the two given vectors in 3D, given by rx = ay*bz - az*by ry = az*bx - a...
double w
Definition: point.h:167
float x
Definition: point.h:139
void PTK_Vector_scale(PTK_Vector *dst, const PTK_Vector *src, float scale)
Perform component-wise scaling of the given PTK Vector and store the result at dst.
void PTK_Vector_d_subtract(PTK_Vector_d *dst, PTK_Vector_d *src1, PTK_Vector_d *src2)
Perform component-wise subtraction, subtracting src2 from src1 and writing the result to dst...
float y
Definition: point.h:222
void PTK_Point_d_tag(PTK_Point_d *pt, uint32_t tag)
This sets tag bits for the given point.
float PTK_Vector_dot3(const PTK_Vector *p1, const PTK_Vector *p2)
Compute the dot product of the two given vectors in 3D, given by r = ax*bx + ay*by + az*bz...
float PTK_Vector_dot2(const PTK_Vector *p1, const PTK_Vector *p2)
Compute the dot product of the two given vectors in 2D, given by r = ax*bx + ay*by.
PTK_Vector PTK_Point
Definition of a point.
Definition: point.h:157
float PTK_Vector_dot4(const PTK_Vector *p1, const PTK_Vector *p2)
Compute the dot product of the two given vectors in 3D, given by r = ax*bx + ay*by + az*bz + aw*bw...
void PTK_Point_set(PTK_Point *dst, float x, float y, float z)
Updates all three components stored within the given PTK_Point to match those given as arguments...
double z
Definition: point.h:196
void PTK_Vector_add(PTK_Vector *dst, const PTK_Vector *src1, const PTK_Vector *src2)
Perform component-wise addition of the vectors stored in src1 and src2, writing the result to dst...
void PTK_Vector_d_add(PTK_Vector_d *dst, PTK_Vector_d *src1, PTK_Vector_d *src2)
Perform component-wise addition of the vectors stored in src1 and src2, writing the result to dst...
void PTK_Point_d_untag(PTK_Point_d *pt, uint32_t tag)
This removes tag bits for the given point.
Definition of a 2D point.
Definition: point.h:216