/
BirdLeon
/
ROBLOX2016
Обзор
Документация
Войти
/
BirdLeon
/
ROBLOX2016
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
Network/include/network/CompactCFrame.h
80 строк
2 KB
PatoFlamejanteTV
full source code
19 дек 2024, 19:11
19 дек 2024, 19:11
05db15d
Код
Авторство
О чём код?
#pragma once #include "Util/Math.h" namespace RBX { class CompactCFrame { Vector3 rotationaxis; float rotationangle; // angle is always positive. public: Vector3 translation; CompactCFrame() : rotationangle(0) {} CompactCFrame(const CoordinateFrame& cframe) : translation(cframe.translation) { cframe.rotation.toAxisAngle(rotationaxis, rotationangle); RBXASSERT(!Math::hasNanOrInf(rotationaxis)); RBXASSERT(!Math::isNanInf(rotationangle)); } CompactCFrame(const Vector3& translation, const Vector3& axisAngle) : translation(translation) , rotationaxis(axisAngle) { rotationangle = rotationaxis.unitize(); RBXASSERT(!Math::hasNanOrInf(rotationaxis)); RBXASSERT(!Math::isNanInf(rotationangle)); } CompactCFrame(const Vector3& translation, const Vector3& axis, float angle) : translation(translation) { setAxisAngle(axis, angle); RBXASSERT(!Math::hasNanOrInf(rotationaxis)); RBXASSERT(!Math::isNanInf(rotationangle)); } void setAxisAngle(const Vector3& axis, float angle) { // enforce angle > 0. if(angle >= 0) { rotationaxis = axis; rotationangle = angle; } else { rotationaxis = axis * -1.0f; rotationangle = -angle; } } CoordinateFrame getCFrame() const { CoordinateFrame answer(Matrix3::fromAxisAngleFast(rotationaxis, rotationangle), translation); RBXASSERT(!Math::hasNanOrInf(answer)); return answer; } Vector3 getAxisAngle() const { return rotationaxis * rotationangle; } const Vector3& getAxis() const { return rotationaxis; } float getAngle() const { return rotationangle; } }; }