Пример #1
0
    //----------------------------------------------------------------------------------------------
		ChsVector3 screenToVector( float scrX, float scrY )const{
      // Scale to screen
      float x   = (scrX - this->halfScreenWidth )  / (this->radius * this->halfScreenWidth );
      float y   = -(scrY -this->halfScreenHeight ) / (this->radius * this->halfScreenHeight );
      float z   = 0.0f;
      float mag = x * x + y * y;
      
      if( mag > 1.0f ) {
        float scale = 1.0f/sqrtf(mag);
        x *= scale;
        y *= scale;
      }
      else{
        z = sqrtf( 1.0f - mag );
      }
      // Return vector
      return ChsVector3( x, y, z );
    }
Пример #2
0
	//----------------------------------------------------------------------------------------------
	ChsVector3 ChsVector3::operator / ( float scale )const{
		assert( scale != 0 );
		return ChsVector3( this->x / scale, this->y / scale, this->z / scale );
	}
Пример #3
0
	//----------------------------------------------------------------------------------------------
	ChsVector3 ChsVector3::operator - ( void )const{
		return ChsVector3( -this->x, -this->y, -this->z );
	}
Пример #4
0
	//----------------------------------------------------------------------------------------------
	ChsVector3 ChsVector3::operator * ( float scale )const{
		return ChsVector3( this->x * scale, this->y * scale, this->z * scale );
	}
Пример #5
0
	//----------------------------------------------------------------------------------------------
	ChsVector3 ChsVector3::cross( const ChsVector3 & vec1, const ChsVector3 & vec2 ){
		return ChsVector3( vec1.y * vec2.z - vec2.y * vec1.z,
						  vec1.z * vec2.x - vec2.z * vec1.x,
						  vec1.x * vec2.y - vec2.x * vec1.y );
	}