11 Sphere(float3 centre, float r, float hue) :
24 /*Sphere(const Sphere& other) :
33 void setCentre(const float3
& centre
)
35 this->centre
= centre
;
46 void setHueInitial(float hue
)
48 this->T
= asinf(2 * hue
- 1) - 3 * PI
/ 2;
55 float hSquare(float2 xySol
) const
57 const float a
= (this->centre
.x
- xySol
.x
);
58 const float b
= (this->centre
.y
- xySol
.y
);
63 * Est-ce que la sphre se trouve en dessous d'un point (x, y) en fonction de h².
64 * Voir la méthode 'hCarre(..)'.
67 bool isBelow(float hCarre
) const
69 return hCarre
< this->rCarre
;
73 * Hauteur du point de collision du rayon par rapport au centre de la sphère.
76 float dz(float hCarre
) const
78 return sqrtf(rCarre
- hCarre
);
82 float distance(float dz
) const
84 return this->centre
.z
- dz
;
88 * Renvoie la le B de HSB compris entre 0 et 1.
91 float brightness(float dz
) const
100 float hue(float t
) const
102 return 0.5 + 0.5 * sinf(t
+ this->T
+ 3 * PI
/ 2);
107 float3 centre
; // Position.
109 float rCarre
; // Précalul de r².
111 float T
; // Utilisé pour l'animation.