Commit Graph

97 Commits

Author SHA1 Message Date
Rémi Verschelde
23fc8e22a3
Merge pull request #95303 from EIREXE/inverted_composer
Fix `Projection::invert` for orthographic projection
2024-11-20 17:03:03 +01:00
Álex Román
02b2efc668 Fix Projection::invert on orthogonal projections and others.
Fixes #68878, specially when using orthographic projection.

Also adds some tests.
2024-11-18 16:13:04 +01:00
kobewi
5c0f2414cd Always add decimal when printing float 2024-10-23 15:00:21 +02:00
Rémi Verschelde
d1caac5e75
Merge pull request #93856 from timothyqiu/expression-period
Fix parsing of `4.` in Expression
2024-09-11 12:34:39 +02:00
Aaron Franke
7db24a9ad5
Simplify and fix Rect2/AABB get_support function 2024-08-19 23:55:31 -07:00
A Thousand Ships
ea2e6be0a6
[Tests] Fix some invalid error messages
These used `utf8().get_data()` when they should be passed as `String`
2024-07-10 15:57:52 +02:00
Haoyu Qiu
ee9cea521d Fix parsing of 4. in Expression 2024-07-02 20:53:52 +08:00
A Thousand Ships
17929a3443
[Tests] Fix unit tests in template builds 2024-06-29 18:35:50 +02:00
Rémi Verschelde
972181d701
Merge pull request #90506 from Calinou/test-transform2d-add-more-tests
Add more unit tests for Transform2D
2024-05-29 22:13:35 +02:00
lawnjelly
b35264ad95 Fix AABB Ray intersection - return inside
* Separates find_intersects from test_intersects for rays, and wraps the former.
* Changes parameter name to "r_intersection_point".
* Fixes broken old version which returned per axis t.
* Returns whether the ray origin is within the AABB.
* Returns intersection point when origin outside.
* Returns "backtracking" intersection point when inside.
* Returns sensible normal when inside.
* Returns valid results on borders.
* Returns robust results dealing with floating point error.

Co-authored-by: Claire Blackshaw <evilkimau@gmail.com>
2024-05-09 20:41:19 +01:00
Rémi Verschelde
7d03b1de0b
Style: Trim trailing whitespace and ensure newline at EOF
Found by apply the file_format checks again via #91597.
2024-05-08 10:12:46 +02:00
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
titus125
ca3ff2b89e
Add more unit tests for Transform2D 2024-04-10 23:17:15 +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