• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2008 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef bts_FLT16VEC2D_EM_H
18 #define bts_FLT16VEC2D_EM_H
19 
20 /* ---- includes ----------------------------------------------------------- */
21 
22 #include "b_BasicEm/Basic.h"
23 #include "b_BasicEm/Phase.h"
24 #include "b_TensorEm/Int16Vec2D.h"
25 
26 /* ---- related objects  --------------------------------------------------- */
27 
28 /* ---- typedefs ----------------------------------------------------------- */
29 
30 /* ---- constants ---------------------------------------------------------- */
31 
32 /* ---- object definition -------------------------------------------------- */
33 
34 /** 2d vector with floating point */
35 struct bts_Flt16Vec2D
36 {
37 
38 	/* ---- private data --------------------------------------------------- */
39 
40 	/* ---- public data ---------------------------------------------------- */
41 
42 	/** x component */
43 	int16 xE;
44 
45 	/** y component */
46 	int16 yE;
47 
48 	/** point position */
49 	int16 bbpE;
50 };
51 
52 /* ---- associated objects ------------------------------------------------- */
53 
54 /* ---- external functions ------------------------------------------------- */
55 
56 /* ---- \ghd{ constructor/destructor } ------------------------------------- */
57 
58 /** initializes vector */
59 void bts_Flt16Vec2D_init( struct bts_Flt16Vec2D* ptrA );
60 
61 /** destroys vector */
62 void bts_Flt16Vec2D_exit( struct bts_Flt16Vec2D* ptrA );
63 
64 /* ---- \ghd{ operators } -------------------------------------------------- */
65 
66 /** copy operator */
67 void bts_Flt16Vec2D_copy( struct bts_Flt16Vec2D* ptrA, const struct bts_Flt16Vec2D* srcPtrA );
68 
69 /** equal operator */
70 flag bts_Flt16Vec2D_equal( const struct bts_Flt16Vec2D* ptrA, const struct bts_Flt16Vec2D* srcPtrA );
71 
72 /* ---- \ghd{ query functions } -------------------------------------------- */
73 
74 /* ---- \ghd{ modify functions } ------------------------------------------- */
75 
76 /* ---- \ghd{ memory I/O } ------------------------------------------------- */
77 
78 /* ---- \ghd{ exec functions } --------------------------------------------- */
79 
80 /** creates vector from 16 bit values */
81 struct bts_Flt16Vec2D bts_Flt16Vec2D_create16( int16 xA, int16 yA, int16 bbpA );
82 
83 /** creates vector from 16 bit vactor */
84 struct bts_Flt16Vec2D bts_Flt16Vec2D_createVec16( struct bts_Int16Vec2D vecA, int16 bbpA );
85 
86 /** creates vector from 32 bit values (automatic adjustment of bbp value) */
87 struct bts_Flt16Vec2D bts_Flt16Vec2D_create32( int32 xA, int32 yA, int32 bbpA );
88 
89 
90 /** dot product of vectors; return bbp is  vec1PtrA->bbpE + vec2PtrA->bbpE */
91 int32 bts_Flt16Vec2D_dotPrd( const struct bts_Flt16Vec2D* vec1PtrA,
92 							 const struct bts_Flt16Vec2D* vec2PtrA );
93 
94 /** returns square norm of vector; return bbp is  ptrA->bbpE * 2 */
95 uint32 bts_Flt16Vec2D_norm2( const struct bts_Flt16Vec2D* ptrA );
96 
97 /** returns norm of vector; return bbp is ptrA->bbpE*/
98 uint16 bts_Flt16Vec2D_norm( const struct bts_Flt16Vec2D* ptrA );
99 
100 /** normalizes vector; bbpA defines number of bits behind the point */
101 void bts_Flt16Vec2D_normalize( struct bts_Flt16Vec2D* ptrA );
102 
103 /** returns normalized vector; bbpA defines number of bits behind the point */
104 struct bts_Flt16Vec2D bts_Flt16Vec2D_normalized( const struct bts_Flt16Vec2D* ptrA );
105 
106 /** computes angle between vector and x axis*/
107 phase16 bts_Flt16Vec2D_angle( const struct bts_Flt16Vec2D* vecPtrA );
108 
109 /** computes angle between two vectors */
110 phase16 bts_Flt16Vec2D_enclosedAngle( const struct bts_Flt16Vec2D* vec1PtrA,
111 									  const struct bts_Flt16Vec2D* vec2PtrA );
112 
113 /** adds two vectors; returns resulting vector */
114 struct bts_Flt16Vec2D bts_Flt16Vec2D_add( struct bts_Flt16Vec2D vec1A, struct bts_Flt16Vec2D vec2A );
115 
116 /** subtracts vec1A - vec2A; returns resulting vector */
117 struct bts_Flt16Vec2D bts_Flt16Vec2D_sub( struct bts_Flt16Vec2D vec1A, struct bts_Flt16Vec2D vec2A );
118 
119 /** multiplies vecor with scalar; returns resulting vector */
120 struct bts_Flt16Vec2D bts_Flt16Vec2D_mul( struct bts_Flt16Vec2D vecA, int16 factorA, int32 bbpFactorA );
121 
122 /** converts vecA into bts_Int16Vec2D */
123 struct bts_Int16Vec2D bts_Flt16Vec2D_int16Vec2D( struct bts_Flt16Vec2D vecA, int32 dstBbpA );
124 
125 #endif /* bts_FLT16VEC2D_EM_H */
126 
127