src/miscallenous.cpp

changeset 1022
a7f8ce5aa858
parent 1014
f0a8ecb6a357
child 1023
9450ac3cd930
equal deleted inserted replaced
1021:f40c792c9334 1022:a7f8ce5aa858
92 } 92 }
93 93
94 94
95 int gcd (int a, int b) 95 int gcd (int a, int b)
96 { 96 {
97 if (a > 0 and b > 0) 97 while (b != 0)
98 { 98 {
99 while (a != b) 99 int temp = a;
100 { 100 a = b;
101 if (a < b) 101 b = temp % b;
102 b -= a;
103 else
104 a -= b;
105 }
106 } 102 }
107 103
108 return a; 104 return a;
109 } 105 }
110 106
111 107
112 void simplify (int& numer, int& denom) 108 void simplify (int& numerator, int& denominator)
113 { 109 {
114 int factor = gcd (numer, denom); 110 int factor = gcd(numerator, denominator);
115 numer /= factor; 111 numerator /= factor;
116 denom /= factor; 112 denominator /= factor;
117 } 113 }
118 114
119 115
120 Vertex getRotationPoint (const LDObjectList& objs) 116 Vertex getRotationPoint (const LDObjectList& objs)
121 { 117 {

mercurial