use of org.jwildfire.create.tina.base.XYZPoint in project JWildfire by thargor6.
the class Loonie2Func method transform.
@Override
public void transform(FlameTransformationContext pContext, XForm pXForm, XYZPoint pAffineTP, XYZPoint pVarTP, double pAmount) {
/* loonie2 by dark-beam, http://dark-beam.deviantart.com/art/Loonie2-update-2-Loonie3-457414891 */
double xrt = pAffineTP.x, yrt = pAffineTP.y, swp;
// r2 = xrt; // normal
// +star
double r2 = xrt * _coss + fabs(yrt) * _sins;
double circle = sqrt(sqr(xrt) + sqr(yrt));
int i;
for (i = 0; i < sides - 1; i++) {
// rotate around to get the the sides!!! :D
swp = xrt * _cosa - yrt * _sina;
yrt = xrt * _sina + yrt * _cosa;
xrt = swp;
// r2 = MAX(r2, xrt); // normal
// +star
r2 = Math.max(r2, xrt * _coss + fabs(yrt) * _sins);
}
// +circle
r2 = r2 * _cosc + circle * _sinc;
if (i > 1) {
// we want it squared, for the pretty effect
r2 = sqr(r2);
} else {
// 2-faces effect JUST FOR i=1
r2 = fabs(r2) * r2;
}
if (r2 > 0 && (r2 < _sqrvvar)) {
double r = pAmount * sqrt(fabs(_sqrvvar / r2 - 1.0));
pVarTP.x += r * pAffineTP.x;
pVarTP.y += r * pAffineTP.y;
} else if (r2 < 0) {
// 2-faces effect JUST FOR i=1
double r = pAmount / sqrt(fabs(_sqrvvar / r2) - 1.0);
pVarTP.x += r * pAffineTP.x;
pVarTP.y += r * pAffineTP.y;
} else {
pVarTP.x += pAmount * pAffineTP.x;
pVarTP.y += pAmount * pAffineTP.y;
}
if (pContext.isPreserveZCoordinate()) {
pVarTP.z += pAmount * pAffineTP.z;
}
}
use of org.jwildfire.create.tina.base.XYZPoint in project JWildfire by thargor6.
the class PostPointSymmetryWFFunc method transform.
@Override
public void transform(FlameTransformationContext pContext, XForm pXForm, XYZPoint pAffineTP, XYZPoint pVarTP, double pAmount) {
double dx = (pVarTP.x - centre_x) * pAmount;
double dy = (pVarTP.y - centre_y) * pAmount;
int idx = pContext.random(order);
pVarTP.x = centre_x + dx * _cosa[idx] + dy * _sina[idx];
pVarTP.y = centre_y + dy * _cosa[idx] - dx * _sina[idx];
}
use of org.jwildfire.create.tina.base.XYZPoint in project JWildfire by thargor6.
the class PRose3DFunc method transform.
@Override
public void transform(FlameTransformationContext pContext, XForm pXForm, XYZPoint pAffineTP, XYZPoint pVarTP, double pAmount) {
// pRose3D by Larry Berlin, http://aporev.deviantart.com/gallery/#/d2blmhg
int posNeg = 1;
double th = 0.0;
// ?? offset as variable? or preset calculated value?
double sth, cth, pang, wig, wag, wag2, wag3, wag12 = 0.0, waggle = 0.0, ghostPrep;
double length = this.l;
double numPetals = this.k;
double constant = this.c;
double scaleZ1 = this.z1;
double scaleZ2 = this.z2;
double smooth12 = fabs(this.opt);
double smooth3 = fabs(this.opt3);
double opScale = fabs(this.optSc);
// Sets the testing limit for randoms to determine transparency
double ghost = sqr(this.transp);
double wagScale = this.wagsc;
double curveScale = this.crvsc;
double frequency = this.f * M_2PI;
double wigScale = this.wigsc * 0.5;
double rad = sqrt(sqr(pAffineTP.x) + sqr(pAffineTP.y));
double curve1 = rad / length;
double curve2 = sqr(rad / length);
double curve3 = (rad - length * 0.5) / length;
double curve4 = sqr(sqr(rad / length));
if (smooth12 > 2.0) {
smooth12 = 2.0;
}
double antiOpt1 = 2.0 - smooth12;
ghostPrep = pContext.getRandGen().random();
// returns the angle this point has with the axis
th = atan2(pAffineTP.y, pAffineTP.x);
sth = sin(th);
cth = cos(th);
this._optDir = Math.copySign(1.0, this.opt);
this._petalsSign = Math.copySign(1.0, this.k);
if (this.opt3 < 0.0) {
this._optDir = -1.0;
}
if (smooth3 > 1.0) {
smooth3 = 1.0;
}
if (length == 0.0) {
length = 0.000001;
}
if (fabs(numPetals) < 0.0001) {
// need a non-zero minimum
numPetals = 0.0001 * this._petalsSign;
}
if (pContext.getRandGen().random() < 0.5) {
posNeg = -1;
}
if (this._cycle == 0.0) {
// point's angle location relative to which petal it belongs to
pang = th / this._cycle + EPSILON;
} else {
// point's angle location relative to which petal it belongs to
pang = th / this._cycle;
}
// circumference relative offset, with high frequency values, this causes the ripples to progress along the perimeter
wig = pang * frequency * 0.5 + this.offset * this._cycle;
// Develop means to structure Z
if (this._optDir < 0.0) {
// length anchored
wag = sin(curve1 * M_PI * opScale) + wagScale * 0.4 * rad + curveScale * 0.5 * (sin(curve2 * M_PI));
// length anchored
wag3 = sin(curve4 * M_PI * opScale) + wagScale * sqr(rad) * 0.4 + curveScale * 0.5 * (cos(curve3 * M_PI));
} else {
// two curveScale methods
wag = sin(curve1 * M_PI * opScale) + wagScale * 0.4 * rad + curveScale * 0.5 * (cos(curve3 * M_PI));
// length anchored
wag3 = sin(curve4 * M_PI * opScale) + wagScale * sqr(rad) * 0.4 + curveScale * 0.5 * (sin(curve2 * M_PI));
}
// length anchored
wag2 = sin(curve2 * M_PI * opScale) + wagScale * 0.4 * rad + curveScale * 0.5 * (cos(curve3 * M_PI));
if (smooth12 <= 1.0) {
wag12 = wag;
} else if (smooth12 <= 2.0 && smooth12 > 1.0) {
wag12 = wag2 * (1.0 - antiOpt1) + wag * antiOpt1;
} else if (smooth12 > 2.0) {
wag12 = wag2;
}
if (smooth3 == 0.0) {
waggle = wag12;
} else if (smooth3 > 0.0) {
waggle = wag12 * (1.0 - smooth3) + wag3 * smooth3;
}
if (this._optDir > 0.0) {
ghost = 0.0;
}
if (// occasion to draw reflection... but only when posNeg is negative
ghostPrep < ghost) {
if (// ghost starts with the reflection transparent
posNeg < 0) {
pVarTP.x += pAmount * 0.5 * this.refSc * (length * cos(numPetals * th + constant)) * cth;
pVarTP.y += pAmount * 0.5 * this.refSc * (length * cos(numPetals * th + constant)) * sth;
// adjustable height
pVarTP.z += pAmount * -0.5 * ((scaleZ2 * waggle + sqr(rad * 0.5) * sin(wig) * wigScale) + (this.dist));
} else {
pVarTP.x += pAmount * 0.5 * (length * cos(numPetals * th + constant)) * cth;
pVarTP.y += pAmount * 0.5 * (length * cos(numPetals * th + constant)) * sth;
pVarTP.z += pAmount * 0.5 * ((scaleZ1 * waggle + sqr(rad * 0.5) * sin(wig) * wigScale) + (this.dist));
}
} else // this is the option when optDir > 0.0
{
pVarTP.x += pAmount * 0.5 * (length * cos(numPetals * th + constant)) * cth;
pVarTP.y += pAmount * 0.5 * (length * cos(numPetals * th + constant)) * sth;
pVarTP.z += pAmount * 0.5 * ((scaleZ1 * waggle + sqr(rad * 0.5) * sin(wig) * wigScale) + (this.dist));
}
}
use of org.jwildfire.create.tina.base.XYZPoint in project JWildfire by thargor6.
the class Pie3DFunc method transform.
@Override
public void transform(FlameTransformationContext pContext, XForm pXForm, XYZPoint pAffineTP, XYZPoint pVarTP, double pAmount) {
int sl = (int) (pContext.random() * slices + 0.5);
double a = rotation + 2.0 * M_PI * (sl + pContext.random() * thickness) / slices;
double r = pAmount * pContext.random();
double sina = sin(a);
double cosa = cos(a);
pVarTP.x += r * cosa;
pVarTP.y += r * sina;
pVarTP.z += r * sin(r);
}
use of org.jwildfire.create.tina.base.XYZPoint in project JWildfire by thargor6.
the class PieFunc method transform.
@Override
public void transform(FlameTransformationContext pContext, XForm pXForm, XYZPoint pAffineTP, XYZPoint pVarTP, double pAmount) {
int sl = (int) (pContext.random() * slices + 0.5);
double a = rotation + 2.0 * M_PI * (sl + pContext.random() * thickness) / slices;
double r = pAmount * pContext.random();
double sina = sin(a);
double cosa = cos(a);
pVarTP.x += r * cosa;
pVarTP.y += r * sina;
if (pContext.isPreserveZCoordinate()) {
pVarTP.z += pAmount * pAffineTP.z;
}
}
Aggregations