blob: 8aff22f6838f21fa19369ebf51a443e3bf795ff0 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
/*
* This file is part of the AzerothCore Project. See AUTHORS file for Copyright information
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published by the
* Free Software Foundation; either version 3 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
*
* Utility library to define some global function for simple physics calculations
*
*/
#ifndef _ACORE_PHYSICS_H
#define _ACORE_PHYSICS_H
#include "Geometry.h"
#include <cmath>
#include <cstdlib>
#include <iostream>
using namespace std;
[[nodiscard]] inline float getWeight(float height, float width, float specificWeight)
{
auto volume = getCylinderVolume(height, width / 2.0f);
auto weight = volume * specificWeight;
return weight;
}
/**
* @brief Get the height immersed in water
*
* @param height
* @param width
* @param weight specific weight
* @return float
*/
[[nodiscard]] inline float getOutOfWater(float width, float weight, float density)
{
auto baseArea = getCircleAreaByRadius(width / 2.0f);
return weight / (baseArea * density);
}
#endif // _ACORE_PHYSICS_H
|