Commit Graph

85 Commits

Author SHA1 Message Date
Joel Kuntz
26feefa91c Add notes for remap's return when istart and istop are the same
Co-Authored-By: Rémi Verschelde <rverschelde@gmail.com>
Co-Authored-By: kleonc <9283098+kleonc@users.noreply.github.com>
2024-05-07 19:37:29 -03:00
Ricardo Buring
8a28f816d0 Replace Clipper1 library by Clipper2 library 2024-04-20 13:37:59 +02:00
Rémi Verschelde
0f7452fedd
Merge pull request #61013 from Calinou/test-add-transform3d
Add rotation unit tests for Transform3D
2024-04-19 16:26:31 +02:00
Alex Billedeaux
f421d20280
Add closest_points_between_segments() basis path tests for Geometry2D 2024-04-10 23:49:23 +02:00
Hugo Locurcio
4e6de25540
Add rotation unit tests for Transform3D
Co-authored-by: Alexander Pruss <alex.pruss@gmail.com>
2024-04-10 22:27:14 +02:00
nazarii
b8caf9b224 Add unit test for Vector2 plane_project 2024-04-05 21:57:01 +03:00
Aaron Franke
158fcf107c
Fix some uses of float and real_t in core/math 2024-03-29 16:44:12 -07:00
A Thousand Ships
b4191bf8f6
[Core] Fix AABB.encloses failing on shared upper bound
This differs from `Rect2(i)` and was fixed for those classes in the past
2024-01-12 17:58:42 +01:00
Rémi Verschelde
22e880ad20
Merge pull request #83163 from Chubercik/vectorXi_dist_methods
Implement `Vector2i/3i/4i` methods: `distance_to` and `distance_squared_to`
2024-01-03 09:58:36 +01:00
EddieBreeg
8747c67d9e
Fix potential integer underflow in rounded up divisions
A new `Math::division_round_up()` function was added, allowing for easy
and correct computation of integer divisions when the result needs to
be rounded up.

Fixes #80358.

Co-authored-by: Rémi Verschelde <rverschelde@gmail.com>
2024-01-02 14:14:47 +01:00
Aaron Franke
7ee273723d
Fix Basis is_orthogonal and is_rotation methods, add is_orthonormal 2023-12-06 13:12:05 -06:00
Jakub Marcowski
cb954c6bab Implement Vector2i/3i/4i methods: distance_to and distance_squared_to 2023-10-12 13:46:49 +02:00
etti
3a39de4e2f Add rotate_toward and angle_difference to GDScript and C# 2023-10-01 22:19:42 +02:00
Rémi Verschelde
3ec673085b
Merge pull request #79523 from aaronfranke/is-conformal
Add `is_conformal` method to Basis and Transform2D
2023-09-26 13:44:41 +02:00
Aaron Franke
bcfb2c0089
Simplify Geometry3D tests 2023-09-25 01:54:22 -05:00
Aaron Franke
56806ffeed
Add is_conformal method to Basis and Transform2D 2023-09-13 17:20:30 -05:00
AcatXIo
7d69a5ba50 Fix sign(NAN) returning 1.
Fixes #79036. sign(NAN) now returns 0.
This should not impact performance much in any way.
Adds a test for the NAN case. Updates the documentation to clarify the new behavior.
2023-09-09 11:30:11 +02:00
Jcrespo
528a76486c Add inverse hyperbolic functions asinh(), acosh() & atanh()
GDScript has the following built-in trigonometry functions:

- `sin()`
- `cos()`
- `tan()`
- `asin()`
- `acos()`
- `atan()`
- `atan()`
- `sinh()`
- `cosh()`
- `tanh()`

However, it lacks the hyperbolic arc (also known as inverse
hyperbolic) functions:

- `asinh()`
- `acosh()`
- `atanh()`

Implement them by just exposing the C++ Math library, but clamping
its values to the closest real defined value.
For the cosine, clamp input values lower than 1 to 1.
In the case of the tangent, where the limit value is infinite,
clamp it to -inf or +inf.

References #78377
Fixes godotengine/godot-proposals#7110
2023-09-01 01:27:56 +02:00
Rémi Verschelde
863bcd3e2b
Merge pull request #76936 from clayjohn/revert-hsl
Revert "Add API for HSL conversion"
2023-05-12 10:03:21 +02:00
Rémi Verschelde
fd4a06c515
Merge pull request #76906 from lawnjelly/safe_acos4_2
Make acos and asin safe
2023-05-11 13:33:37 +02:00
lawnjelly
50c5ed4876 Make acos and asin safe
A common bug with using acos and asin is that input outside -1 to 1 range will result in Nan output. This can occur due to floating point error in the input.

The standard solution is to provide safe_acos function with clamped input. For Godot it may make more sense to make the standard functions safe.
2023-05-11 08:34:34 +01:00
clayjohn
f83a90192f Revert "Add API for HSL conversion"
This reverts commit 0b7fd664c1.
2023-05-10 17:45:56 -03:00
Rémi Verschelde
703a3ce7ad
Merge pull request #76830 from ajreckof/fix_wrapf_CI_with_too_big_float
fix a test for wrapf with signed 32-bit float
2023-05-10 10:20:03 +02:00
bonjorno7
0b7fd664c1 Add API for HSL conversion
Math ported pretty much 1:1 from https://en.wikipedia.org/wiki/HSL_and_HSV
Style doesn't match the existing HSV code exactly, but should be close enough.
2023-05-09 17:43:10 +02:00
ajreckof
fabd9535f0 fix a test for wrapf with signed 32-bit float 2023-05-08 20:53:58 +02:00
Andrés Botero
a90e151b2a Added component-wise min and max functions for vectors 2023-02-11 15:03:11 -05:00
Aaron Franke
5f3d3722b2
Add support for interpolating skewed transforms 2023-01-28 18:28:42 -06:00
Rémi Verschelde
5b1df48c6c
Convert en_GB spelling to en_US with codespell 2023-01-23 11:02:20 +01:00
Raul Santos
7560340ef6
Rename center method to get_center in Plane. 2023-01-15 17:18:50 +01:00
Rémi Verschelde
d95794ec8a
One Copyright Update to rule them all
As many open source projects have started doing it, we're removing the
current year from the copyright notice, so that we don't need to bump
it every year.

It seems like only the first year of publication is technically
relevant for copyright notices, and even that seems to be something
that many companies stopped listing altogether (in a version controlled
codebase, the commits are a much better source of date of publication
than a hardcoded copyright statement).

We also now list Godot Engine contributors first as we're collectively
the current maintainers of the project, and we clarify that the
"exclusive" copyright of the co-founders covers the timespan before
opensourcing (their further contributions are included as part of Godot
Engine contributors).

Also fixed "cf." Frenchism - it's meant as "refer to / see".
2023-01-05 13:25:55 +01:00
Rémi Verschelde
4a8b725bc9
Merge pull request #68386 from MewPurPur/snappedi-snappedf
Implement snappedi, snappedf, and Vector[2/3/4]i.snapped
2022-11-24 18:54:49 +01:00
VolTer
e26f0906f2 Implement snappedi, snappedf, and Vector[2/3/4]i.snapped 2022-11-19 06:18:55 +01:00
Hendrik Brucker
1f36dbdf23 Generic math function tests: Test float and double variants 2022-11-09 01:51:55 +01:00
Hendrik Brucker
f906ff8f89 [Tests] Replace Math::is_equal_approx with == and doctest::Approx 2022-11-05 02:28:00 +01:00
Hendrik Brucker
e62955b45b Add a test suite for Math:: namespace functions
Co-authored-by: Hugo Locurcio <hugo.locurcio@hugo.pro>
2022-11-04 03:08:08 +01:00
Aaron Franke
9e952c8386
Allow getting Quaternion rotation in different Euler orders 2022-11-02 19:20:10 -05:00
Rémi Verschelde
08d56ac2f1
Merge pull request #66747 from aaronfranke/move-euler-order
Move EulerOrder enum to math_defs.h and global scope
2022-11-02 22:37:12 +01:00
Aaron Franke
8556fdd4bc
Move EulerOrder enum to math_defs.h and global scope 2022-11-02 13:44:13 -05:00
Rémi Verschelde
f7c611ab71
Style: Misc docs and comment style and language fixes
- Removed empty paragraphs in XML.
- Consistently use bold style for "Example:", on a new line.
- Fix usage of `[code]` when hyperlinks could be used (`[member]`, `[constant]`).
- Fix invalid usage of backticks for inline code in BBCode.
- Fix some American/British English spelling inconsistencies.
- Other minor fixes spotted along the way, including typo fixes with codespell.
- Don't specify `@GlobalScope` for `enum` and `constant`.
2022-11-02 19:01:18 +01:00
Aaron Franke
83634119d4
Replace Quaternion Euler constructor with from_euler method 2022-11-01 09:28:12 -05:00
Aaron Franke
fae4ed5a98
Simplify Euler order test code in test_basis.h 2022-10-27 12:10:57 -05:00
Aaron Franke
7f9a8c99c9
Clean up Basis from Euler code 2022-10-21 17:54:49 -05:00
Haoyu Qiu
5da515773d Add is_finite method for checking built-in types 2022-10-08 13:25:08 +08:00
Rémi Verschelde
d9a3888cea Merge pull request #66133 from aaronfranke/set-all
Delete `set_all`, `set_axis`, and `get_axis` methods from Vector2/3/3i/4/4i
2022-10-03 09:23:46 +02:00
Rémi Verschelde
166df0896c Fix typos with codespell
Using codespell 2.3-dev from current git.

And fix typo in `methods.py` for `vsproj=yes` option (still won't work
though).
2022-09-30 14:23:36 +02:00
Micky
ef8fbae929
Add more tests for Vector* types 2022-09-25 22:58:58 -05:00
Aaron Franke
fd8bd27657
Remove set_axis and get_axis methods from Vector2/2i/3/3i/4/4i 2022-09-19 15:08:50 -05:00
fabriceci
9f1a57d48b Test, refactor and fix a bug in Basis.get_axis_angle 2022-09-14 12:05:22 +02:00
Aaron Franke
995b9f94e8
Replace Rect2(i) has_no_area with has_area 2022-09-04 23:03:36 -05:00
Aaron Franke
817ae95667
Replace AABB has_no_volume with has_volume
Also replace has_no_surface with has_surface
2022-09-04 23:03:36 -05:00