Contexto: soy gráficos de computadora programador de mirar un código de implementación. Necesito ayuda para la comprensión de una función que no ha sido documentado adecuadamente ni comentado.
Dado un círculo con la circunferencia de la $c$ en el espacio de coordenadas Cartesianas. Ahora cada punto de este círculo está definida por coordenadas Cartesianas $(x, y)$.
Necesito algunas explicaciones en cuanto a lo que los cálculos siguientes lograr, por favor, disculpe el uso indebido de los símbolos:
$$ \begin{align} nX = \frac {x}{c}\\ nY = \frac {y}{c} \end{align} $$
I believe $n$ stands for 'normal' or vector. then...
$$ \begin{align} rdX = nX \cdot 2\pi\\ rdY = nY \cdot \pi \end{align} $$
I assume 'rd' stands for radians. What really puzzles me here is why nX is multiplied with $2\pi$, while $nY$ is only multiplied by $\pi$.
$$ \begin{align} \sin Y = \sin(rdY + \pi) \end{align} $$
En este punto estoy completamente perdido...
ahora por fin: $$ \begin{align} a = 2\pi\cdot\sin(rdX)\cdot\sin Y\\ b = 2\pi\cdot\cos(rdX)\cdot\sin Y\\ d = 2\pi\cdot\cos(rdy) \end{align} $$
Very simple question; What is being calculated here? What do a,b and d represent? At first i figured that this was a conversion from Cartesian coordinates to spherical coordinates. But given a closer look, this is not at all how I would calculate them. What am I looking at here?
EDIT:
I will include the source of these calculations to clarify their context. They are part of a library that provides functions for working with Simplex Noise.
They appear in functions that sample a generated noise field. This noise field can be sampled in n-dimensions. This sampling means that I provide a set of parameters (usually coordinates) to the noise functions, which return a noise value, eg:
var noiseValue = simplexNoise.get2DNoise( x, y )
var noiseValue = simplexNoise.get3DNoise( x, y, z )
var noiseValue = simplexNoise.get4DNoise( x, y, z, w )
An example:
If I generate a grid of points in a plane dimension (two dimensions), and then sample noise values of those points using their coordinates:
z = simplexNoise.get2DNoise( x, y )
Then now I suddenly have a third dimension. This to say i started with this, and ended up sampling my z values to result in this. The noise function assures me that I do not have completely random values.
Now however, I want to sample noise on a spherical surface. And I encounter these two functions:
FastSimplexNoise.prototype.getSpherical2DNoise = function (c, x, y) {
var nx = x / c;
var ny = y / c;
var rdx = nx * 2 * Math.PI;
var rdy = ny * Math.PI;
var sinY = Math.sin(rdy + Math.PI);
var sinRds = 2 * Math.PI;
var a = sinRds * Math.sin(rdx) * sinY;
var b = sinRds * Math.cos(rdx) * sinY;
var d = sinRds * Math.cos(rdy);
return this.get3DNoise(a, b, d);
};
FastSimplexNoise.prototype.getSpherical3DNoise = function (c, x, y, z) {
var nx = x / c;
var ny = y / c;
var rdx = nx * 2 * Math.PI;
var rdy = ny * Math.PI;
var sinY = Math.sin(rdy + Math.PI);
var sinRds = 2 * Math.PI;
var a = sinRds * Math.sin(rdx) * sinY;
var b = sinRds * Math.cos(rdx) * sinY;
var d = sinRds * Math.cos(rdy);
return this.get4DNoise(a, b, d, z);
};
Note in particular that getSpherical3DNoise(c, x, y) ends up sampling the three-dimensional pointvector $(a, b, d)$, given only an $( x,y )$ coordinate and circumference $c$
The second function, getSpherical3DNoise(c, x, y, z) seems like an incomprehensible follow-up to the previous function by sampling a four-dimensional vector $(a, b, d, z)$, $z$ being the Cartesian coordinate along the $z$-eje
Estas funciones se comportan de forma extraña, por decir lo menos. Así que ellos son incomprehansably hábilmente escrito. O que garantiza una reescritura.