/** Zeros the linear and angular components of this steering acceleration. * @return this steering acceleration for chaining */ public SteeringAcceleration<T> setZero () { linear.setZero(); angular = 0f; return this; }
/** Utility method that creates a new vector. * <p> * This method is used internally to instantiate vectors of the correct type parameter {@code T}. This technique keeps the API * simple and makes the API easier to use with the GWT backend because avoids the use of reflection. * * @param location the location whose position is used to create the new vector * @return the newly created vector */ protected T newVector (Location<T> location) { return location.getPosition().cpy().setZero(); } }
public JumpTarget (Steerable<T> other) { this.position = null; this.linearVelocity = other.getPosition().cpy().setZero(); }
/** Creates a {@code FieldOfViewProximity} for the specified owner, agents and cone area defined by the given radius and angle * in radians. * @param owner the owner of this proximity * @param agents the agents * @param radius the radius of the cone area * @param angle the angle in radians of the cone area */ public FieldOfViewProximity (Steerable<T> owner, Iterable<? extends Steerable<T>> agents, float radius, float angle) { super(owner, agents); this.radius = radius; setAngle(angle); this.lastTime = 0; this.ownerOrientation = owner.getPosition().cpy().setZero(); this.toAgent = owner.getPosition().cpy().setZero(); }
/** Creates a {@code RayConfigurationBase} for the given owner and the specified number of rays. * @param owner the owner of this configuration * @param numRays the number of rays used by this configuration */ @SuppressWarnings("unchecked") public RayConfigurationBase (Steerable<T> owner, int numRays) { this.owner = owner; this.rays = new Ray[numRays]; for (int i = 0; i < numRays; i++) this.rays[i] = new Ray<T>(owner.getPosition().cpy().setZero(), owner.getPosition().cpy().setZero()); }
@Override public Location<T> calculateSlotLocation (Location<T> outLocation, int slotNumber) { if (numberOfSlots > 1) { // Place the slot around the circle based on its slot number float angleAroundCircle = (MathUtils.PI2 * slotNumber) / numberOfSlots; // The radius depends on the radius of the member, // and the number of members in the circle: // we want there to be no gap between member's shoulders. float radius = memberRadius / (float)Math.sin(Math.PI / numberOfSlots); // Fill location components based on the angle around circle. outLocation.angleToVector(outLocation.getPosition(), angleAroundCircle).scl(radius); // The members should be facing out outLocation.setOrientation(angleAroundCircle); } else { outLocation.getPosition().setZero(); outLocation.setOrientation(MathUtils.PI2 * slotNumber); } // Return the slot location return outLocation; }
/** Zeros the linear and angular components of this steering acceleration. * @return this steering acceleration for chaining */ public SteeringAcceleration<T> setZero () { linear.setZero(); angular = 0f; return this; }
steering.linear.setZero();
/** Calculates the drift offset when members are in the given set of slots for the specified pattern. * @param centerOfMass the output location set to the calculated drift offset * @param slotAssignments the set of slots * @param pattern the pattern * @return the given location for chaining. */ public Location<T> calculateDriftOffset (Location<T> centerOfMass, Array<SlotAssignment<T>> slotAssignments, FormationPattern<T> pattern) { // Clear the center of mass centerOfMass.getPosition().setZero(); float centerOfMassOrientation = 0; // Make sure tempLocation is instantiated if (tempLocation == null) tempLocation = centerOfMass.newLocation(); T centerOfMassPos = centerOfMass.getPosition(); T tempLocationPos = tempLocation.getPosition(); // Go through each assignment and add its contribution to the center float numberOfAssignments = slotAssignments.size; for (int i = 0; i < numberOfAssignments; i++) { pattern.calculateSlotLocation(tempLocation, slotAssignments.get(i).slotNumber); centerOfMassPos.add(tempLocationPos); centerOfMassOrientation += tempLocation.getOrientation(); } // Divide through to get the drift offset. centerOfMassPos.scl(1f / numberOfAssignments); centerOfMassOrientation /= numberOfAssignments; centerOfMass.setOrientation(centerOfMassOrientation); return centerOfMass; }
/** Utility method that creates a new vector. * <p> * This method is used internally to instantiate vectors of the correct type parameter {@code T}. This technique keeps the API * simple and makes the API easier to use with the GWT backend because avoids the use of reflection. * * @param location the location whose position is used to create the new vector * @return the newly created vector */ protected T newVector (Location<T> location) { return location.getPosition().cpy().setZero(); } }
public JumpTarget (Steerable<T> other) { this.position = null; this.linearVelocity = other.getPosition().cpy().setZero(); }
/** Creates a {@code RayConfigurationBase} for the given owner and the specified number of rays. * @param owner the owner of this configuration * @param numRays the number of rays used by this configuration */ @SuppressWarnings("unchecked") public RayConfigurationBase (Steerable<T> owner, int numRays) { this.owner = owner; this.rays = new Ray[numRays]; for (int i = 0; i < numRays; i++) this.rays[i] = new Ray<T>(owner.getPosition().cpy().setZero(), owner.getPosition().cpy().setZero()); }
/** Creates a {@code FieldOfViewProximity} for the specified owner, agents and cone area defined by the given radius and angle * in radians. * @param owner the owner of this proximity * @param agents the agents * @param radius the radius of the cone area * @param angle the angle in radians of the cone area */ public FieldOfViewProximity (Steerable<T> owner, Iterable<? extends Steerable<T>> agents, float radius, float angle) { super(owner, agents); this.radius = radius; setAngle(angle); this.lastTime = 0; this.ownerOrientation = owner.getPosition().cpy().setZero(); this.toAgent = owner.getPosition().cpy().setZero(); }
@Override public Location<T> calculateSlotLocation (Location<T> outLocation, int slotNumber) { if (numberOfSlots > 1) { // Place the slot around the circle based on its slot number float angleAroundCircle = (MathUtils.PI2 * slotNumber) / numberOfSlots; // The radius depends on the radius of the member, // and the number of members in the circle: // we want there to be no gap between member's shoulders. float radius = memberRadius / (float)Math.sin(Math.PI / numberOfSlots); // Fill location components based on the angle around circle. outLocation.angleToVector(outLocation.getPosition(), angleAroundCircle).scl(radius); // The members should be facing out outLocation.setOrientation(angleAroundCircle); } else { outLocation.getPosition().setZero(); outLocation.setOrientation(MathUtils.PI2 * slotNumber); } // Return the slot location return outLocation; }
steering.linear.setZero();
/** Calculates the drift offset when members are in the given set of slots for the specified pattern. * @param centerOfMass the output location set to the calculated drift offset * @param slotAssignments the set of slots * @param pattern the pattern * @return the given location for chaining. */ public Location<T> calculateDriftOffset (Location<T> centerOfMass, Array<SlotAssignment<T>> slotAssignments, FormationPattern<T> pattern) { // Clear the center of mass centerOfMass.getPosition().setZero(); float centerOfMassOrientation = 0; // Make sure tempLocation is instantiated if (tempLocation == null) tempLocation = centerOfMass.newLocation(); T centerOfMassPos = centerOfMass.getPosition(); T tempLocationPos = tempLocation.getPosition(); // Go through each assignment and add its contribution to the center float numberOfAssignments = slotAssignments.size; for (int i = 0; i < numberOfAssignments; i++) { pattern.calculateSlotLocation(tempLocation, slotAssignments.get(i).slotNumber); centerOfMassPos.add(tempLocationPos); centerOfMassOrientation += tempLocation.getOrientation(); } // Divide through to get the drift offset. centerOfMassPos.scl(1f / numberOfAssignments); centerOfMassOrientation /= numberOfAssignments; centerOfMass.setOrientation(centerOfMassOrientation); return centerOfMass; }