I cant seem to find any Unreal unit converter programs out there, i did find one actually but it doesnt work for me so i figure just make my own, but the problem is i dont even know where to start. How do i begin? i want to convert feet, centimeters, inches, and meters, i want to be able to convert to and from real units and unreal units. So how would i go about doing something like this? please explain in as much and best detail as possible. Fo those of you who dont know what an Unreal Unit is, its a unit of measurement used by Unreal Engine 3. Here is a chart showing the UU and what they convert to in real life.
Because 16uu equals 12 inches, or, 1 foot. It should just be / 16, not * 12 / 16. You only multiply by 12 to get inches. It might also be beneficial to make either macros or an enum to set up the conversion.
Because you're rounding the conversion rate. The best way to get an accurate answer is to do this:
convert to inches first: uu / 16 * 12
convert to cm next: inches * 2.54
Wait i just realized something, i need to convert real life units to unreal units -.-, so would i just revers my stuff? EX: instead of uuTcm / 0.525 would it be 0.525 / uuTcm?
No, it would be multiplication. Also, you still need to go step by step. You're also going to be entering inches, or feet, or cms, or meters and need to convert back to feet then convert to uu.
#include <iostream>
float FeetToUU(float number) { return (number * 16.0); }
float InchesToUU(float number) { return FeetToUU(number / 12.0); }
float CMToUU(float number) { return InchesToUU(number / 2.54); }
float MetersToUU(float number) { return CMToUU(number * 100.0); }
int main() {
std::cout << "Please select an option\n"
<< "\n"
<< "1) Feet to UU\n"
<< "2) Inches to UU\n"
<< "3) Centimeters to UU\n"
<< "4) Meters to UU\n"
<< "\n";
int selection;
std::cin >> selection;
float number;
switch (selection) {
case 1:
std::cout << "\nPlease enter number of inches: ";
std::cin >> number;
std::cout << "\n" << number << " inches = " << InchesToUU(number) << " UU";
break;
case 2:
std::cout << "\nPlease enter number of feet: ";
std::cin >> number;
std::cout << "\n" << number << " feet = " << FeetToUU(number) << " UU";
break;
case 3:
std::cout << "\nPlease enter number of centimeters: ";
std::cin >> number;
std::cout << "\n" << number << " centimeters = " << CMToUU(number) << " UU";
break;
case 4:
std::cout << "\nPlease enter number of meters: ";
std::cin >> number;
std::cout << "\n" << number << " meters = " << MetersToUU(number) << " UU";
break;
default:
std::cout << "\nNot a valid option!";
break;
}
return 0;
}
It's very basic, but I just called the functions to convert it in the proper order. I didn't have actual values to test. But I do believe that is right.