void ofxBehavior::init() { bEnabled = true; bAllocatedMagnitude = true; magnitude = new float; setMagnitude(1.0); }
void ofxBehavior::init() { bAllocatedEnabled = true; bEnabled = new bool; setEnabled(true); bAllocatedMagnitude = true; magnitude = new float; setMagnitude(1.0); }
void basicMove(float targetPosition[3], float targetVelocityMagnitude) { // This function is designed to take a targetPosition, and a targetVelocityMagnitude to be at when it reaches that position. // If you want to stop there, set the targetVelocity to 0, and this function will simply use setPositionTarget. // If, however, you do not wish to stop, this will try to be as close as possible to the target velocity when it arrives. // If is entirely possible, that even with a reasonably low targetVelocityMagitude it will not be able to reach it. if (targetVelocityMagnitude == 0) { // Setting position target if you want to stop there. api.setPositionTarget(targetPosition); } else { // Setting up the required vectors. float targetVelocity[3]; float requiredAcceleration[3]; float requiredForce[3]; // Initially just gets the direction of the required velocity, which is identical to the displacement between where you are and where you want to be. mathVecSubtract(targetVelocity, targetPosition, position, 3); if (!mathVecMagnitude(targetVelocity, 3)) { // If silly stuff is happening and this is zero, don't try to apply forces. api.setPositionTarget(targetPosition); return; } // Then it sets the magnitude of the targetVelocity to what you want it to be. setMagnitude(targetVelocity, targetVelocityMagnitude); // Then it works out how much you have to accelerate to make it to that this second. // a = (v - u) / t (But t is 1). mathVecSubtract(requiredAcceleration, targetVelocity, velocity, 3); // Then, F = ma multiplyVectorByScalar(requiredForce, requiredAcceleration, mass); // But, if it couldn't actually apply this much force, it reduces it to the maximum force it can apply. // (Found to be ~0.05N through experimentation). // While acctually applying more would be fine, it would make mass predictions wildly inaccurate. if (mathVecMagnitude(requiredForce, 3) > maxForce) { setMagnitude(requiredForce, maxForce); } // Here it actually sets the force. api.setForces(requiredForce); // And here it records it for use in updateMass() lastForceMagnitude = mathVecMagnitude(requiredForce, 3); } }
void move(float targetPosition[3]) { // This function is designed to get from place to place, using basicMove(), but to account for the asteroid. float wayPoint[3]; // The current way point to be used. bool isWayPoint = false; // Is the point you end up going to a wayPoint? closestPointInIntervalToPoint(wayPoint, origin, position, targetPosition); // The wayPoint is the closes point to the asteroid. // But, if it is inside the raidus, it needs to be adjusted. int x = 0; while (mathVecMagnitude(wayPoint, 3) <= dangerZoneRadius + sphereRadius + 0.02f && x < 5) { x ++; isWayPoint = true; setMagnitude(wayPoint, dangerZoneRadius + sphereRadius + 0.02f); closestPointInIntervalToPoint(wayPoint, origin, position, wayPoint); // Setting to check if there is a point along this line. } // If the path passes through the origin for instance, the wayPoint will be null // Don't use paths which pass through the origin. if (isWayPoint && mathVecMagnitude(wayPoint, 3)) { basicMove(wayPoint, 0.04f); } else { basicMove(targetPosition, 0.0f); } }
void copyMagnitude(const Vector *inputVector, Vector *outputVector) { double mag = magnitude(inputVector); setMagnitude(outputVector, mag); }
Vector :: Vector(double magnitude, double direction) { setMagnitude(magnitude); setDirection(direction); _totalVectors++; }
void nextPhotoPos(float position[3]) { unsigned short int i = nextPhotoID(); game.getPOILoc(position, i % 3); setMagnitude(position, (i < 3) ? 0.475 : 0.385); }
void ComplexFloatArray::setMagnitude(FloatArray magnitude, ComplexFloatArray destination){ setMagnitude(magnitude, 0, size, destination); }
void ComplexFloatArray::setMagnitude(FloatArray magnitude, int offset, int count){ setMagnitude(magnitude, offset, count, *this); }
void ComplexFloatArray::setMagnitude(FloatArray magnitude){ setMagnitude(magnitude, 0, size); }