public void emit() { for (int i = 1; i <= emitNum; i++) { Particle x = new Particle(loc.x, loc.y, 0, null); if (images != null) { x.setImage(images[(int) randomP(images.length)]); } else { x.setImage(null); } double temp = angle2 - angle1; double newAngle = (((rnd.nextDouble() * temp) + angle1) * Math.PI / 180); if (randomV) { x.setVel( randomP(xSpeed) * FastMath.cos(newAngle), randomP(ySpeed) * FastMath.sin(newAngle), 0); } else { x.setVel(xSpeed * FastMath.cos(newAngle), ySpeed * FastMath.sin(newAngle), 0); } x.setFade(fade); x.setFadeRate(fadeRate); x.setLoc(loc.x + random(spreadX), loc.y + random(spreadY), 0); x.setAcc(xAcc, yAcc, 0); x.setMaxAge(maxAge); x.setMaxSize(maxSize); x.setSize(size); x.setAgeRate(ageRate); x.setGrowthRate(growthRate); x.setBlink(blink); x.setColor(color); x.setMaxSpeed(new Vector3D(maxXSpeed, maxYSpeed, 0)); particleManager.addParticle(x); } }
/** * <code>fromAngles</code> builds a Quaternion from the Euler rotation angles (y,r,p). Note that * we are applying in order: roll, pitch, yaw but we've ordered them in x, y, and z for * convenience. See: * http://www.euclideanspace.com/maths/geometry/rotations/conversions/eulerToQuaternion/index.htm * * @param yaw the Euler yaw of rotation (in radians). (aka Bank, often rot around x) * @param roll the Euler roll of rotation (in radians). (aka Heading, often rot around y) * @param pitch the Euler pitch of rotation (in radians). (aka Attitude, often rot around z) */ public Quaternion fromAngles(float yaw, float roll, float pitch) { float angle; float sinRoll, sinPitch, sinYaw, cosRoll, cosPitch, cosYaw; angle = pitch * 0.5f; sinPitch = FastMath.sin(angle); cosPitch = FastMath.cos(angle); angle = roll * 0.5f; sinRoll = FastMath.sin(angle); cosRoll = FastMath.cos(angle); angle = yaw * 0.5f; sinYaw = FastMath.sin(angle); cosYaw = FastMath.cos(angle); // variables used to reduce multiplication calls. float cosRollXcosPitch = cosRoll * cosPitch; float sinRollXsinPitch = sinRoll * sinPitch; float cosRollXsinPitch = cosRoll * sinPitch; float sinRollXcosPitch = sinRoll * cosPitch; w = (cosRollXcosPitch * cosYaw - sinRollXsinPitch * sinYaw); x = (cosRollXcosPitch * sinYaw + sinRollXsinPitch * cosYaw); y = (sinRollXcosPitch * cosYaw + cosRollXsinPitch * sinYaw); z = (cosRollXsinPitch * cosYaw - sinRollXcosPitch * sinYaw); normalize(); return this; }
/** * <code>fromAngleNormalAxis</code> sets this quaternion to the values specified by an angle and a * normalized axis of rotation. * * @param angle the angle to rotate (in radians). * @param axis the axis of rotation (already normalized). */ public Quaternion fromAngleNormalAxis(float angle, Vector3f axis) { if (axis.x == 0 && axis.y == 0 && axis.z == 0) { loadIdentity(); } else { float halfAngle = 0.5f * angle; float sin = FastMath.sin(halfAngle); w = FastMath.cos(halfAngle); x = sin * axis.x; y = sin * axis.y; z = sin * axis.z; } return this; }