载入中...
搜索中...
未找到
Vec3.h
浏览该文件的文档.
1#pragma once
2#include "common/Export.h"
3
4
5#include <cmath>
6
7namespace eve::math {
8
11public:
12 Vec3() = default;
14 Vec3(float x, float y, float z) : x_(x), y_(y), z_(z) {}
15
17 float getX() const { return x_; }
19 float getY() const { return y_; }
21 float getZ() const { return z_; }
23 void setX(float x) { x_ = x; }
25 void setY(float y) { y_ = y; }
27 void setZ(float z) { z_ = z; }
29 void set(float x, float y, float z) {
30 x_ = x;
31 y_ = y;
32 z_ = z;
33 }
34
36 float length() const { return std::sqrt(x_ * x_ + y_ * y_ + z_ * z_); }
38 float lengthSquared() const { return x_ * x_ + y_ * y_ + z_ * z_; }
39
41 void normalize();
42 Vec3 *normalized() const;
43
45 float dot(const Vec3 *other) const;
46 Vec3 *cross(const Vec3 *other) const;
48 float distanceTo(const Vec3 *other) const;
49
51 Vec3 *add(const Vec3 *other) const;
52 Vec3 *sub(const Vec3 *other) const;
53 Vec3 *scale(float s) const;
55 Vec3 *lerpTo(const Vec3 *other, float t) const;
57 Vec3 *clone() const;
58
59private:
60 float x_ = 0.f;
61 float y_ = 0.f;
62 float z_ = 0.f;
63};
64
65} // namespace eve::math
float y
Definition AnimClip.cpp:738
float x
Definition AnimClip.cpp:738
float z
Definition AnimClip.cpp:738
const std::string & s
#define EVENGINE_API_FOUNDATION
每个链接组(link group)各自的导出宏。
Definition Export.h:106
std::array< float, 3 > scale
float t
3D float vector (script-facing math module value).
Definition Vec3.h:10
Vec3()=default
Vec3(float x, float y, float z)
Creates a vector from components.
Definition Vec3.h:14
float getY() const
Y component.
Definition Vec3.h:19
float getZ() const
Z component.
Definition Vec3.h:21
void setX(float x)
Sets the X component.
Definition Vec3.h:23
float length() const
Magnitude (and squared magnitude).
Definition Vec3.h:36
void setY(float y)
Sets the Y component.
Definition Vec3.h:25
float lengthSquared() const
Squared Euclidean magnitude.
Definition Vec3.h:38
void setZ(float z)
Sets the Z component.
Definition Vec3.h:27
float getX() const
Component accessors.
Definition Vec3.h:17
void set(float x, float y, float z)
Sets all three components.
Definition Vec3.h:29