Package processing.core

Examples of processing.core.PVector.dot()


 
  public boolean detect(MassedBeing being1, MassedBeing being2) {
    if(being1 == being2) // no self-interaction
      return false;
    PVector r = PVector.sub(being1.getPosition(), being2.getPosition());
    float d_squared = r.dot(r);
    // check if the distance is within the maximum range
    return d_squared <= _maxRangeSquared && d_squared != 0;
  }

  public void handle(MassedBeing being1, MassedBeing being2) {
View Full Code Here


  }

  public void handle(MassedBeing being1, MassedBeing being2) {
    // F = k * q1 * q2 / r^2
    PVector r = PVector.sub(being2.getPosition(), being1.getPosition());
    double d_squared = (double)r.dot(r);
    double F = _k * beingFactor(being1) * beingFactor(being2) / d_squared;
    r.normalize();
    PVector force = PVector.mult(r, (float)F);
    being2.addForce(force);
    being1.addForce(reverse(force));
View Full Code Here

    assert normal != null : "Physics.calculateImpulse: normal must be a valid PVector";
    assert !(normal.x == 0 && normal.y == 0) : "Physics.calculateImpulse: normal must be nonzero";
   
    PVector numerator = PVector.sub(v2, v1); // calculate relative velocity
    numerator.mult(-1 - elasticity);      // factor by elasticity
    float result = numerator.dot(normal);    // find normal component
    result /= normal.dot(normal);       // normalize
    result /= (1 / m1 + 1 / m2);       // factor in mass
   
    return PVector.mult(normal, result);
  }
View Full Code Here

   */
  private void addAxis(PVector start, PVector end, PVector preStart) {
    PVector axis = PVector.sub(start, end);
    axis.normalize();
    axis = HermesMath.rotate(axis,Math.PI/2);
    float project1 = axis.dot(start);
    float projectpre = axis.dot(preStart);
    assert project1 != projectpre : "HPolygon must be convex!";
    if(project1 < projectpre) {
      reverse(axis);
    }
View Full Code Here

  private void addAxis(PVector start, PVector end, PVector preStart) {
    PVector axis = PVector.sub(start, end);
    axis.normalize();
    axis = HermesMath.rotate(axis,Math.PI/2);
    float project1 = axis.dot(start);
    float projectpre = axis.dot(preStart);
    assert project1 != projectpre : "HPolygon must be convex!";
    if(project1 < projectpre) {
      reverse(axis);
    }
    _axes.add(axis);
View Full Code Here

    float min;
    float max;
   
    Iterator<PVector> points = poly.getPoints().iterator();
    PVector pInit = points.next();
    min = pInit.dot(axis);
    max = min;
   
    while(points.hasNext()) {
      PVector p = points.next();
      float project = p.dot(axis);
View Full Code Here

    min = pInit.dot(axis);
    max = min;
   
    while(points.hasNext()) {
      PVector p = points.next();
      float project = p.dot(axis);
      if(project < min) min = project;
      if(max < project) max = project;
    }
   
    return new PVector(min,max);
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.