Ocean
JSVector4.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) Meta Platforms, Inc. and affiliates.
3  *
4  * This source code is licensed under the MIT license found in the
5  * LICENSE file in the root directory of this source tree.
6  */
7 
8 #ifndef META_OCEAN_INTERACTION_JS_VECTOR_4_H
9 #define META_OCEAN_INTERACTION_JS_VECTOR_4_H
10 
13 
14 namespace Ocean
15 {
16 
17 namespace Interaction
18 {
19 
20 namespace JavaScript
21 {
22 
23 /**
24  * This class implements a wrapper for a JavaScript Vector4 object.
25  * @ingroup interactionjs
26  */
27 class OCEAN_INTERACTION_JS_EXPORT JSVector4 : public JSObject<JSVector4, Vector4>
28 {
29  friend class JSObject<JSVector4, Vector4>;
30  friend class JSLibrary;
31 
32  public:
33 
34  /**
35  * Definition of ids for individual accessors.
36  */
37  enum AccessorId : unsigned int
38  {
39  /// The accessor for the x property, a number value.
41  /// The accessor for the y property, a number value.
43  /// The accessor for the z property, a number value.
45  /// The accessor for the w property, a number value.
46  AI_W
47  };
48 
49  /**
50  * Definition of ids for individual functions.
51  */
52  enum FunctionId : unsigned int
53  {
54  /**
55  * Adds two vectors or adds a scalar value to this vector.
56  * <pre>
57  * Vector4 = Vector4.add(Vector4)
58  * Vector4 = Vector4.add(Number)
59  * </pre>
60  */
62 
63  /**
64  * Determines the angle between two vectors in radian.
65  * <pre>
66  * Number = Vector4.angle(Vector4)
67  * </pre>
68  */
70 
71  /**
72  * Inverts this vector.
73  * <pre>
74  * Vector4.invert()
75  * </pre>
76  */
78 
79  /**
80  * Returns the inverted vector of this vector.
81  * <pre>
82  * Vector4 = Vector4.inverted()
83  * </pre>
84  */
86 
87  /**
88  * Returns whether two vectors are equal up to some epsilon.
89  * <pre>
90  * Boolean = Vector4.isEqual(Vector4)
91  * </pre>
92  */
94 
95  /**
96  * Returns the length of this vector.
97  * <pre>
98  * Number = Vector4.length()
99  * </pre>
100  */
102 
103  /**
104  * Multiplies two vectors to determine the scalar product or multiplies this vector with a scalar.
105  * <pre>
106  * Number = Vector4.multiply(Vector4)
107  * Vector4 = Vector4.multiply(Number)
108  * </pre>
109  */
111 
112  /**
113  * Normalizes this vector so that the vector has unit length afterwards.
114  * <pre>
115  * Vector4.normalize()
116  * </pre>
117  */
119 
120  /**
121  * Returns the normalized vector of this vector, so that the new vector has unit length.
122  * <pre>
123  * Vector4 = Vector4.normalized()
124  * </pre>
125  */
127 
128  /**
129  * Returns a string with the values of this vector.
130  * <pre>
131  * String = Vector4.string()
132  * </pre>
133  */
135 
136  /**
137  * Subtracts two vectors or subtracts a scalar value from this vector.
138  * <pre>
139  * Vector4 = Vector4.subtract(Vector4)
140  * Vector4 = Veccto3.subtract(Number)
141  * </pre>
142  */
143  FI_SUBTRACT
144  };
145 
146  public:
147 
148  /**
149  * Returns the JavaScript name of this object.
150  * @return The object's JavaScript name
151  */
152  static inline const char* objectName();
153 
154  protected:
155 
156  /**
157  * Creates the function template and object template for this object.
158  */
159  static void createFunctionTemplate();
160 };
161 
162 inline const char* JSVector4::objectName()
163 {
164  return "Vector4";
165 }
166 
167 }
168 
169 }
170 
171 }
172 
173 #endif // META_OCEAN_INTERACTION_JS_VECTOR_4_H
This class implements the java script interaction library object.
Definition: JSLibrary.h:32
This class implements the base class for all native wrapper of JavaScript objects.
Definition: JSObject.h:31
This class implements a wrapper for a JavaScript Vector4 object.
Definition: JSVector4.h:28
FunctionId
Definition of ids for individual functions.
Definition: JSVector4.h:53
@ FI_NORMALIZED
Returns the normalized vector of this vector, so that the new vector has unit length.
Definition: JSVector4.h:126
@ FI_ADD
Adds two vectors or adds a scalar value to this vector.
Definition: JSVector4.h:61
@ FI_LENGTH
Returns the length of this vector.
Definition: JSVector4.h:101
@ FI_NORMALIZE
Normalizes this vector so that the vector has unit length afterwards.
Definition: JSVector4.h:118
@ FI_STRING
Returns a string with the values of this vector.
Definition: JSVector4.h:134
@ FI_INVERT
Inverts this vector.
Definition: JSVector4.h:77
@ FI_IS_EQUAL
Returns whether two vectors are equal up to some epsilon.
Definition: JSVector4.h:93
@ FI_INVERTED
Returns the inverted vector of this vector.
Definition: JSVector4.h:85
@ FI_ANGLE
Determines the angle between two vectors in radian.
Definition: JSVector4.h:69
@ FI_MULTIPLY
Multiplies two vectors to determine the scalar product or multiplies this vector with a scalar.
Definition: JSVector4.h:110
AccessorId
Definition of ids for individual accessors.
Definition: JSVector4.h:38
@ AI_X
The accessor for the x property, a number value.
Definition: JSVector4.h:40
@ AI_Y
The accessor for the y property, a number value.
Definition: JSVector4.h:42
@ AI_Z
The accessor for the z property, a number value.
Definition: JSVector4.h:44
static void createFunctionTemplate()
Creates the function template and object template for this object.
static const char * objectName()
Returns the JavaScript name of this object.
Definition: JSVector4.h:162
This class implements a vector with four elements.
Definition: Vector4.h:97
The namespace covering the entire Ocean framework.
Definition: Accessor.h:15