|
![](/i/fill.gif) |
:
: If you want others to be able to use your diff you better make it in
: context format, 3 lines before/after changes used to be the rule.
: Otherwise your diff can only be patched to the exact same source level
: you diff'd with.
:
Here is a diff in the unified format (3 lines before/after changes).
Massimo
--- povray-3.50a/src/super.cpp Fri Oct 18 12:45:32 2002
+++ povray-3.50b/src/super.cpp Tue Oct 22 11:18:09 2002
@@ -476,29 +476,39 @@
static void Superellipsoid_Normal(VECTOR Result, OBJECT *Object, INTERSECTION *Inter)
{
- DBL k, x, y, z;
- VECTOR P, N, E;
SUPERELLIPSOID *Superellipsoid = (SUPERELLIPSOID *)Object;
+ VECTOR const& E = Superellipsoid->Power;
+ VECTOR P, N;
/* Transform the point into the superellipsoid space. */
MInvTransPoint(P, Inter->IPoint, Superellipsoid->Trans);
- Assign_Vector(E, Superellipsoid->Power);
-
- x = fabs(P[X]);
- y = fabs(P[Y]);
- z = fabs(P[Z]);
+ DBL r, z2n = 0;
+ if (P[Z] != 0)
+ {
+ z2n = power(fabs(P[Z]), E[Z]);
+ P[Z] = z2n / P[Z];
+ }
- k = power(power(x, E[X]) + power(y, E[X]), E[Y] - 1.0);
+ if (fabs(P[X]) > fabs(P[Y]))
+ {
+ r = power(fabs(P[Y] / P[X]), E[X]);
- N[X] = k * SGNX(P[X]) * power(x, E[X] - 1.0);
- N[Y] = k * SGNX(P[Y]) * power(y, E[X] - 1.0);
- N[Z] = SGNX(P[Z]) * power(z, E[Z] - 1.0);
+ P[X] = (1-z2n) / P[X];
+ P[Y] = P[Y] ? (1-z2n) * r / P[Y] : 0;
+ }
+ else if (P[Y] != 0)
+ {
+ r = power(fabs(P[X] / P[Y]), E[X]);
+ P[X] = P[X] ? (1-z2n) * r / P[X] : 0;
+ P[Y] = (1-z2n) / P[Y];
+ }
+ if (P[Z]) P[Z] *= (1 + r);
/* Transform the normalt out of the superellipsoid space. */
- MTransNormal(Result, N, Superellipsoid->Trans);
+ MTransNormal(Result, P, Superellipsoid->Trans);
VNormalize(Result, Result);
}
@@ -1082,16 +1092,29 @@
* Oct 1994 : Creation.
*
******************************************************************************/
+static DBL my_g(DBL x, DBL y, DBL e)
+{
+ DBL g = 0;
+ if (x > y)
+ {
+ g = 1 + power(y/x, e);
+ if (g != 1) g = power(g, 1/e);
+ g *= x;
+ }
+ else if (y != 0)
+ {
+ g = 1 + power(x/y, e);
+ if (g != 1) g = power(g, 1/e);
+ g *= y;
+ }
+ return g;
+}
static DBL evaluate_superellipsoid(VECTOR P, SUPERELLIPSOID *Superellipsoid)
{
- VECTOR V1;
-
- V1[X] = power(fabs(P[X]), Superellipsoid->Power[X]);
- V1[Y] = power(fabs(P[Y]), Superellipsoid->Power[X]);
- V1[Z] = power(fabs(P[Z]), Superellipsoid->Power[Z]);
-
- return(power(V1[X] + V1[Y], Superellipsoid->Power[Y]) + V1[Z] - 1.0);
+ DBL f = my_g(fabs(P[X]), fabs(P[Y]), Superellipsoid->Power[X]);
+ f = my_g(f, fabs(P[Z]), Superellipsoid->Power[Z]);
+ return f - 1;
}
Post a reply to this message
|
![](/i/fill.gif) |