Skip to content

Setting rotation to PI is not equal to PI #108071

Closed as not planned
Closed as not planned
@Logharn

Description

@Logharn

Tested versions

Reproducible in: 4.4.1.stable

System information

Windows 11 - Godot Engine v4.4.1.stable.official.49a5bc7b6 - https://godotengine.org Vulkan 1.4.303 - Forward+ - Using Device #0: NVIDIA - NVIDIA GeForce RTX 4060 Ti

Issue description

Setting the rotation of a node to PI, is then approximated to a bit more than PI.

Steps to reproduce

Create a new project.
Create a Sprite2D node.
Add "icon.svg" as texture of Sprite2D.
Add a Timer as child of Sprite2D.
Attach a new script to Sprite2D.
Fill it with this code:

extends Sprite2D

# Called when the node enters the scene tree for the first time.
func _ready() -> void:
	$Timer.timeout.connect(on_timer_timeout)
	self.rotation = 0

func on_timer_timeout() -> void:
	print(self.rotation)
	self.rotation += PI

	if self.rotation >= TAU:
		print(PI)
		rotation = 0

The console Output will be:

0.0
3.14159274101257
3.14159265358979
0.0
3.14159274101257
3.14159265358979
...

In the inspector the rotation is reported correctly as 180.0° because it is rounded but in code is 180.000005008956

Minimal reproduction project (MRP)

Ready made project

rotation_test.zip

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions