emrainey / hobbies

A place to collect and share all my hobby projects.
The Unlicense
0 stars 1 forks source link

Add toroidal mapping 3d -> 2d for "textures" #14

Closed emrainey closed 2 months ago

emrainey commented 2 years ago

Add a method to translate any point on a torus to a 2d point (2 angles). The first is the angle to the R3::basis::X in the XY plane. The second is the rotation around the donut (find through dot ?)

emrainey commented 2 months ago

Claude.ai answered that we should use:

u = (atan2(y, x) + π) / (2π)
v = (atan2(z, sqrt((sqrt(x² + y²) - R)² + z²) - R) + π) / (2π)
emrainey commented 2 months ago

Claude.ai is incorrect. It's just

u = (atan2(y, x) + pi) / 2pi
r = sqrt(x^2 + y^2)
d = r - R
v = (atan2(z, d) + pi) / 2pi