/// <summary> /// Mutator - Make sure the face index is in range [0,6); UV coordinate normalization handled in UVCoordinate /// </summary> private void normalize() { if (6 <= face_index_variable || face_index_variable < 0) { face_index_variable = (int)PlanetariaMath.modolo_using_euclidean_division(face_index_variable, 6); // HACK: CONSIDER: would anyone ever enter something like 2^31 in here? } }
// Methods (non-Public) /// <summary> /// Mutator - Wrap UV coordinates so that neither value is outside of [0,1]. /// </summary> private void normalize() { if (data_variable.x < 0 || data_variable.x > 1) { data_variable.x = PlanetariaMath.modolo_using_euclidean_division(data_variable.x, 1); // TODO: does this work? } else if (data_variable.x == 0) { data_variable.x = Precision.just_above_zero; } else if (data_variable.x == 1) { data_variable.x = Precision.just_below_one; } if (data_variable.y < 0 || data_variable.y > 1) { data_variable.y = PlanetariaMath.modolo_using_euclidean_division(data_variable.y, 1); } else if (data_variable.y == 0) { data_variable.y = Precision.just_above_zero; } else if (data_variable.y == 1) { data_variable.y = Precision.just_below_one; } }
/*public static implicit operator OctahedronUVCoordinates(NormalizedSphericalCoordinates spherical) * { * return (NormalizedCartesianCoordinates) spherical; * }*/ /// <summary> /// Mutator - Wrap elevation and azimuth so they are within [0, PI] and [0, 2*PI) respectively. /// </summary> private void normalize() // FIXME: verify - it's been wrong until now at least { if (data_variable.x < -Mathf.PI / 2 || data_variable.x > +Mathf.PI / 2) { data_variable.x = PlanetariaMath.modolo_using_euclidean_division(data_variable.x + Mathf.PI / 2, 2 * Mathf.PI); // modulo is undefined behavior with negative numbers if (data_variable.x > Mathf.PI) // result must be positive (due to euclidean division) { data_variable.x = 2 * Mathf.PI - data_variable.x; data_variable.y += Mathf.PI; // going past the pole (to the opposite hemisphere) changes the azimuth } data_variable.x -= Mathf.PI / 2; } if (data_variable.y < 0 || data_variable.y >= 2 * Mathf.PI) { data_variable.y = PlanetariaMath.modolo_using_euclidean_division(data_variable.y, 2 * Mathf.PI); } }