1 /*
2  * Copyright (C) 2023 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 OHOS_RENDER_3D_VEC3_H
17 #define OHOS_RENDER_3D_VEC3_H
18 
19 #include <string>
20 #include "data_type/constants.h"
21 
22 namespace OHOS::Render3D {
23 class Vec3 {
24 public:
Vec3()25     Vec3() {}
Vec3(float x,float y,float z)26     Vec3(float x, float y, float z) : x_(x), y_(y), z_(z) {}
GetX()27     float GetX() const { return x_; }
GetY()28     float GetY() const { return y_; }
GetZ()29     float GetZ() const { return z_; }
SetX(float x)30     void SetX(float x) { x_ = x; }
SetY(float y)31     void SetY(float y) { y_ = y; }
SetZ(float z)32     void SetZ(float z) { z_ = z; }
33 
34 private:
35     union {
36         struct {
37             float x_ = 0.0f;
38             float y_ = 0.0f;
39             float z_ = 0.0f;
40         };
41         float data_[3];
42     };
43 };
44 } // namespace OHOS::Render3D
45 #endif // OHOS_RENDER_3D_VEC3_H
46