Package processing.core

Examples of processing.core.PVector.mag()


    //Get the center of the other circle
    PVector worldCenterOther = PVector.add(other.getPosition(), other.getCenter());
   
    //HCircles are colliding if distance between them is less than sum of radii
    PVector dir = PVector.sub(worldCenterOther, worldCenterThis);
    float distance = dir.mag();
    float sumRadii = _radius + other._radius;
    boolean collides = distance <= sumRadii;
   
    //Projection vector is the unit vector pointing from this circle to other scaled by overlap
    if(collides) {
View Full Code Here


   * @return projection vector when colliding, null when not
   */
  private PVector getOverlap(PVector worldCenter, PVector vertex) {
    //Get vector from circle to vertex and overlap of shapes
    PVector axis = PVector.sub(vertex, worldCenter);
    float overlap = _radius - axis.mag();
    if(overlap >= 0) {
      //Get projection vector
      axis.normalize();
      axis.mult(overlap);
      return axis;
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.