17
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-10-17 15:39:20 +02:00
Files
maszyna/utilities/Float3d.cpp
jerrrrycho 0a7c42c4a9 refactor(sonar): take read-only pointer and reference parameters as const (cpp:S995)
TTrain command handlers keep their signature, it is fixed by the handler table.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-10 17:08:45 +02:00

56 lines
1.4 KiB
C++

/*
This Source Code Form is subject to the
terms of the Mozilla Public License, v.
2.0. If a copy of the MPL was not
distributed with this file, You can
obtain one at
http://mozilla.org/MPL/2.0/.
*/
#include "stdafx.h"
#include "utilities/Float3d.h"
#include "scene/sn_utils.h"
//---------------------------------------------------------------------------
void float4x4::deserialize_float32(std::istream &s)
{
for (auto &elemententry : e)
elemententry = sn_utils::ld_float32(s);
}
void float4x4::deserialize_float64(std::istream &s)
{
for (auto &elemententry : e)
elemententry = (float)sn_utils::ld_float64(s);
}
void float4x4::serialize_float32(std::ostream &s) const
{
for (auto &element : e)
sn_utils::ls_float32(s, element);
}
void float4x4::Quaternion(float4 const *q)
{ // konwersja kwaternionu obrotu na macierz obrotu
float xx = q->x * q->x;
float yy = q->y * q->y;
float zz = q->z * q->z;
float xy = q->x * q->y;
float xz = q->x * q->z;
float yz = q->y * q->z;
float wx = q->w * q->x;
float wy = q->w * q->y;
float wz = q->w * q->z;
e[0] = 1.0f - yy - yy - zz - zz;
e[1] = xy + xy + wz + wz;
e[2] = xz + xz - wy - wy;
e[4] = xy + xy - wz - wz;
e[5] = 1.0f - xx - xx - zz - zz;
e[6] = yz + yz + wx + wx;
e[8] = xz + xz + wy + wy;
e[9] = yz + yz - wx - wx;
e[10] = 1.0f - xx - xx - yy - yy;
// czwartej kolumny i czwartego wiersza nie ruszamy
};