Example #1
0
void CHSVColor::RGBtoHSV(float R, float G, float B)
{
	float MaxValue, MinValue, diff, Rdist, Gdist, Bdist;

	MaxValue = maxofthree(R, G, B);//
	MinValue = minofthree(R, G, B);//
	diff = MaxValue - MinValue;
	m_V = MaxValue;
	if(MaxValue !=0)
		m_S = diff/MaxValue;
	else {
		m_S = 0;
		m_H = 0;
	}
	if(m_S!=0)
	{
		Rdist = (MaxValue - R)/diff;
		Gdist = (MaxValue - G)/diff;
		Bdist = (MaxValue - B)/diff;
		if(R == MaxValue)
			m_H = Bdist - Gdist;
		else if(G == MaxValue)
			m_H = 2+Rdist-Bdist;
		else if(B == MaxValue)
			m_H = 4+Gdist-Rdist;

		m_H = m_H*60;
		if(m_H<0)
			m_H += 360;
	}
}
Example #2
0
int main() {
    printf("%d\n", maxofthree(1, -4, -7));
    printf("%d\n", maxofthree(2, -6,  1));
    printf("%d\n", maxofthree(2,  3,  1));
    printf("%d\n", maxofthree(-2,  4,  3));
    printf("%d\n", maxofthree(2,  -6, 5));
    printf("%d\n", maxofthree(2,  4, 6));

    return 0;
}
Example #3
0
int main()
{
    std::cout << maxofthree(  1, -4, -7 ) << std::endl;
    std::cout << maxofthree(  2, -6,  1 ) << std::endl;
    std::cout << maxofthree(  2,  3,  1 ) << std::endl;
    std::cout << maxofthree( -2,  4,  3 ) << std::endl;
    std::cout << maxofthree(  2, -6,  5 ) << std::endl;
    std::cout << maxofthree(  2,  4,  6 ) << std::endl;
    
    char vendorID[ 20 ];
    memset( vendorID, 0, 20 );
    get_vendor_id( vendorID );
    std::cout << "Vendor ID: " << vendorID << std::endl;
    
    return 0;
}