Fix: adding two vectors with nearly the same angle
This commit is contained in:
		
							parent
							
								
									295a2b3902
								
							
						
					
					
						commit
						99e4515358
					
				@ -34,8 +34,10 @@ Polar Polar::operator+(const Polar& v2) const {
 | 
				
			|||||||
  float deltaAngle = Angle::Normalize(v2.angle - this->angle);
 | 
					  float deltaAngle = Angle::Normalize(v2.angle - this->angle);
 | 
				
			||||||
  float rotation = deltaAngle < 0 ? 180 + deltaAngle : 180 - deltaAngle;
 | 
					  float rotation = deltaAngle < 0 ? 180 + deltaAngle : 180 - deltaAngle;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if (rotation == 180 && v2.distance > 0)
 | 
					  if (rotation == 180 && v2.distance > 0) {
 | 
				
			||||||
    return Polar::zero;
 | 
					    //  angle is too small, take this angle and add the distances
 | 
				
			||||||
 | 
					    return Polar(this->angle, this->distance + v2.distance);
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  float newDistance =
 | 
					  float newDistance =
 | 
				
			||||||
      Angle::CosineRuleSide(v2.distance, this->distance, rotation);
 | 
					      Angle::CosineRuleSide(v2.distance, this->distance, rotation);
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user