mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 06:17:35 +00:00
Everywhere: Use AK/Math.h if applicable
AK's version should see better inlining behaviors, than the LibM one. We avoid mixed usage for now though. Also clean up some stale math includes and improper floatingpoint usage.
This commit is contained in:
parent
c5f6ba6e71
commit
ed46d52252
40 changed files with 116 additions and 156 deletions
|
@ -7,24 +7,24 @@
|
|||
#include "LineTool.h"
|
||||
#include "ImageEditor.h"
|
||||
#include "Layer.h"
|
||||
#include <AK/Math.h>
|
||||
#include <LibGUI/Action.h>
|
||||
#include <LibGUI/Menu.h>
|
||||
#include <LibGUI/Painter.h>
|
||||
#include <math.h>
|
||||
|
||||
namespace PixelPaint {
|
||||
|
||||
static Gfx::IntPoint constrain_line_angle(Gfx::IntPoint const& start_pos, Gfx::IntPoint const& end_pos, float angle_increment)
|
||||
{
|
||||
float current_angle = atan2f(end_pos.y() - start_pos.y(), end_pos.x() - start_pos.x()) + float { M_PI * 2 };
|
||||
float current_angle = AK::atan2<float>(end_pos.y() - start_pos.y(), end_pos.x() - start_pos.x()) + float { M_PI * 2 };
|
||||
|
||||
float constrained_angle = ((int)((current_angle + angle_increment / 2) / angle_increment)) * angle_increment;
|
||||
|
||||
auto diff = end_pos - start_pos;
|
||||
float line_length = sqrt(diff.x() * diff.x() + diff.y() * diff.y());
|
||||
float line_length = AK::hypot<float>(diff.x(), diff.y());
|
||||
|
||||
return { start_pos.x() + (int)(cosf(constrained_angle) * line_length),
|
||||
start_pos.y() + (int)(sinf(constrained_angle) * line_length) };
|
||||
return { start_pos.x() + (int)(AK::cos(constrained_angle) * line_length),
|
||||
start_pos.y() + (int)(AK::sin(constrained_angle) * line_length) };
|
||||
}
|
||||
|
||||
LineTool::LineTool()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue