Overclock.net › Forums › Software, Programming and Coding › Coding and Programming › [C++] A "Basic" Triangle Classifier
New Posts  All Forums:Forum Nav:

[C++] A "Basic" Triangle Classifier - Page 2

post #11 of 12
Thread Starter 
Quote:
Originally Posted by rabidgnome229 View Post
make a function to test for equality

Code:
inline int d_equals(double a, double b){
  return (((a>b) ? (a-b) : (b-a)) < 1/1<<8);
}
Instead of this
Code:
 if (total==3)
              return ("an Acute");
           else if (total==4)
                return ("a Right");
           else if (total==5)
                return ("an Obtuse");
use this
Code:
if (d_equal(total, 3))
              return ("an Acute");
           else if (d_equal(total, 4))
                return ("a Right");
           else if (d_equal(total, 5))
                return ("an Obtuse");
Thanks a lot! +Rep

Also,
Code:
inline int d_equals(double a, double b){
  return (((a>b) ? (a-b) : (b-a)) < 1/1<<8);
}
should be
Code:
inline int d_equal(double a, double b){
  return (((a>b) ? (a-b) : (b-a)) < 1/1<<8);
}
It just stumped me for a second.
Cataclysm
(20 items)
 
  
CPUMotherboardGraphicsRAM
Q6600 G0 GA-EP45-UD3P Rev. 1.0 Sapphire 4850 4x 2GB DDR2-1066 
Hard DriveHard DriveOptical DriveCooling
WD1600AAJS Random IDE Sony DVD Burner Tuniq Tower 120 
CoolingCoolingCoolingOS
6x 120mm Scythe SY1225SL12SH Fans Thermalright T-RAD2 2x 92mm Scythe DFS922512M-PWM Fans Windows 7 Ultimate x64 SP1 
MonitorMonitorKeyboardPower
Acer 19" @ 1400x900 Sceptre 19" @ 1280x1024 Cherry G81-7000LPAUS-2 (MY Switches) Corsair 650TX 
CaseMouseMouse PadAudio
Antec 900 Razer Diamondback 3G A black one with a cat in a hammock Asus Xonar D1 
  hide details  
Reply
Cataclysm
(20 items)
 
  
CPUMotherboardGraphicsRAM
Q6600 G0 GA-EP45-UD3P Rev. 1.0 Sapphire 4850 4x 2GB DDR2-1066 
Hard DriveHard DriveOptical DriveCooling
WD1600AAJS Random IDE Sony DVD Burner Tuniq Tower 120 
CoolingCoolingCoolingOS
6x 120mm Scythe SY1225SL12SH Fans Thermalright T-RAD2 2x 92mm Scythe DFS922512M-PWM Fans Windows 7 Ultimate x64 SP1 
MonitorMonitorKeyboardPower
Acer 19" @ 1400x900 Sceptre 19" @ 1280x1024 Cherry G81-7000LPAUS-2 (MY Switches) Corsair 650TX 
CaseMouseMouse PadAudio
Antec 900 Razer Diamondback 3G A black one with a cat in a hammock Asus Xonar D1 
  hide details  
Reply
post #12 of 12
Thread Starter 
I added this congruency function that uses a lot of ifs. I just hope it's perfect because I don't want to try to weed through it.

Also, thanks again for that decimal checker function.

Edit: Thank god it works!
Edit 2: Lol, it actually just returns 1 every time. Any ideas?

Code:
int congruency (double distab, double distbc, double distca, double distde, double distef, double distfd)
{
       if (d_equals(distab, distde)){
          if (d_equals(distbc, distef)){
             if (d_equals(distca, distfd)){
                return 1;}}
          else if (d_equals(distbc, distfd)){
                  if (d_equals(distca, distef)){
                    return 1;}}}
       else if (d_equals(distab, distef)){
               if (d_equals(distbc, distde)){
                  if (d_equals(distca, distfd)){
                     return 1;}}
               else if (d_equals(distbc, distfd)){
                       if (d_equals(distca, distde)){
                          return 1;}}}
       else if (d_equals(distab, distfd)){
               if (d_equals(distbc, distde)){
                  if (d_equals(distca, distef)){
                     return 1;}}
               else if (d_equals(distbc, distef)){
                       if (d_equals(distca, distde)){
                          return 1;}}}
       else
           return 0;
Cataclysm
(20 items)
 
  
CPUMotherboardGraphicsRAM
Q6600 G0 GA-EP45-UD3P Rev. 1.0 Sapphire 4850 4x 2GB DDR2-1066 
Hard DriveHard DriveOptical DriveCooling
WD1600AAJS Random IDE Sony DVD Burner Tuniq Tower 120 
CoolingCoolingCoolingOS
6x 120mm Scythe SY1225SL12SH Fans Thermalright T-RAD2 2x 92mm Scythe DFS922512M-PWM Fans Windows 7 Ultimate x64 SP1 
MonitorMonitorKeyboardPower
Acer 19" @ 1400x900 Sceptre 19" @ 1280x1024 Cherry G81-7000LPAUS-2 (MY Switches) Corsair 650TX 
CaseMouseMouse PadAudio
Antec 900 Razer Diamondback 3G A black one with a cat in a hammock Asus Xonar D1 
  hide details  
Reply
Cataclysm
(20 items)
 
  
CPUMotherboardGraphicsRAM
Q6600 G0 GA-EP45-UD3P Rev. 1.0 Sapphire 4850 4x 2GB DDR2-1066 
Hard DriveHard DriveOptical DriveCooling
WD1600AAJS Random IDE Sony DVD Burner Tuniq Tower 120 
CoolingCoolingCoolingOS
6x 120mm Scythe SY1225SL12SH Fans Thermalright T-RAD2 2x 92mm Scythe DFS922512M-PWM Fans Windows 7 Ultimate x64 SP1 
MonitorMonitorKeyboardPower
Acer 19" @ 1400x900 Sceptre 19" @ 1280x1024 Cherry G81-7000LPAUS-2 (MY Switches) Corsair 650TX 
CaseMouseMouse PadAudio
Antec 900 Razer Diamondback 3G A black one with a cat in a hammock Asus Xonar D1 
  hide details  
Reply
New Posts  All Forums:Forum Nav:
  Return Home
  Back to Forum: Coding and Programming
Overclock.net › Forums › Software, Programming and Coding › Coding and Programming › [C++] A "Basic" Triangle Classifier