Add operator== and operator!= to Vector3
This commit is contained in:
		
							parent
							
								
									a5fd16e5b3
								
							
						
					
					
						commit
						b631875246
					
				
					 2 changed files with 24 additions and 0 deletions
				
			
		| 
						 | 
				
			
			@ -142,6 +142,27 @@ Vector3::operator-()
 | 
			
		|||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * Vector3::operator== --
 | 
			
		||||
 * Vector3::operator!= --
 | 
			
		||||
 *
 | 
			
		||||
 * Compute boolean equality and non-equality of this and the given vectors.
 | 
			
		||||
 */
 | 
			
		||||
bool
 | 
			
		||||
Vector3::operator==(const Vector3 &rhs)
 | 
			
		||||
    const
 | 
			
		||||
{
 | 
			
		||||
    return x == rhs.x && y == rhs.y && z == rhs.z;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
bool
 | 
			
		||||
Vector3::operator!=(const Vector3 &rhs)
 | 
			
		||||
    const
 | 
			
		||||
{
 | 
			
		||||
    return !(*this == rhs);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * Vector3::length2 --
 | 
			
		||||
 *
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -28,6 +28,9 @@ struct Vector3
 | 
			
		|||
    Vector3 operator-(const Vector3 &rhs) const;
 | 
			
		||||
    Vector3 operator-() const;
 | 
			
		||||
 | 
			
		||||
    bool operator==(const Vector3 &rhs) const;
 | 
			
		||||
    bool operator!=(const Vector3 &rhs) const;
 | 
			
		||||
 | 
			
		||||
    float length2() const;
 | 
			
		||||
    float length() const;
 | 
			
		||||
    float dot(const Vector3 &v) const;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue