• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef FOUNDATION_ACE_FRAMEWORKS_BASE_GEOMETRY_NG_PROPERTIES_VECTORF_H
17 #define FOUNDATION_ACE_FRAMEWORKS_BASE_GEOMETRY_NG_PROPERTIES_VECTORF_H
18 
19 #include "base/utils/utils.h"
20 
21 namespace OHOS::Ace::NG {
22 
23 struct VectorF {
VectorFVectorF24     VectorF(float xF, float yF) : x(xF), y(yF) {}
25 
26     bool operator==(const VectorF& other) const
27     {
28         return NearEqual(x, other.x) && NearEqual(y, other.y);
29     }
30 
31     float x = 0.0f;
32     float y = 0.0f;
33 };
34 
35 struct Vector3F {
36     Vector3F() = default;
Vector3FVector3F37     Vector3F(float xF, float yF, float zF) : x(xF), y(yF), z(zF) {}
38 
39     bool operator==(const Vector3F& other) const
40     {
41         return NearEqual(x, other.x) && NearEqual(y, other.y) && NearEqual(z, other.z);
42     }
43 
44     float operator[](int32_t index) const
45     {
46         switch (index) {
47             case 0:
48                 return x;
49             case 1:
50                 return y;
51             case 2:
52                 return z;
53             default:
54                 return 0.0f;
55         }
56     }
57 
58     float x = 0.0f;
59     float y = 0.0f;
60     float z = 0.0f;
61 };
62 
63 struct Vector4F {
Vector4FVector4F64     Vector4F(float xF, float yF, float zF, float wF) : x(xF), y(yF), z(zF), w(wF) {}
65 
66     bool operator==(const Vector4F& other) const
67     {
68         return NearEqual(x, other.x) && NearEqual(y, other.y) && NearEqual(z, other.z) && NearEqual(w, other.w);
69     }
70 
71     float x = 0.0f;
72     float y = 0.0f;
73     float z = 0.0f;
74     float w = 0.0f;
75 };
76 
77 struct Vector5F {
Vector5FVector5F78     Vector5F(float xF, float yF, float zF, float wF, float vF) : x(xF), y(yF), z(zF), w(wF), v(vF) {}
79 
80     bool operator==(const Vector5F& other) const
81     {
82         return NearEqual(x, other.x) && NearEqual(y, other.y) && NearEqual(z, other.z) &&
83             NearEqual(w, other.w) && NearEqual(v, other.v);
84     }
85 
86     float x = 0.0f;
87     float y = 0.0f;
88     float z = 0.0f;
89     float w = 0.0f;
90     float v = 0.0f;
91 };
92 
93 } // namespace OHOS::Ace::NG
94 #endif // FOUNDATION_ACE_FRAMEWORKS_BASE_GEOMETRY_NG_PROPERTIES_VECTORF_H