Enforce minimum angle of 10 degrees
This commit is contained in:
+3
-8
@@ -61,13 +61,8 @@ TriangleLayer *triangle_layer_create(GRect frame, GColor color) {
|
|||||||
// determine angles
|
// determine angles
|
||||||
uint8_t r1, r2;
|
uint8_t r1, r2;
|
||||||
do {
|
do {
|
||||||
r1 = 1 + (rand() % 179); // 1–178
|
r1 = 10 + (rand() % 151); // 10–160 (angle_A ≥ 10)
|
||||||
r2 = 1 + (rand() % 179); // 1–178
|
r2 = (r1 + 10) + (rand() % (161 - r1)); // r1+10 … 170 (angles B,C ≥ 10)
|
||||||
if (r1 > r2) {
|
|
||||||
uint8_t tmp = r1;
|
|
||||||
r1 = r2;
|
|
||||||
r2 = tmp;
|
|
||||||
}
|
|
||||||
} while (r1 == 60 && r2 == 120); // ensure never equilateral
|
} while (r1 == 60 && r2 == 120); // ensure never equilateral
|
||||||
|
|
||||||
tri->angle_A = r1;
|
tri->angle_A = r1;
|
||||||
@@ -86,7 +81,7 @@ TriangleLayer *triangle_layer_create(GRect frame, GColor color) {
|
|||||||
max_sin = sin_C;
|
max_sin = sin_C;
|
||||||
|
|
||||||
// longest side randomly chosen
|
// longest side randomly chosen
|
||||||
#define MIN_SIDE 20
|
#define MIN_SIDE 40
|
||||||
uint16_t max_side = (frame.size.w < frame.size.h) ? frame.size.w : frame.size.h;
|
uint16_t max_side = (frame.size.w < frame.size.h) ? frame.size.w : frame.size.h;
|
||||||
max_side = max_side - 12; // basic margin
|
max_side = max_side - 12; // basic margin
|
||||||
uint16_t largest_side = MIN_SIDE + (rand() % (max_side - MIN_SIDE + 1));
|
uint16_t largest_side = MIN_SIDE + (rand() % (max_side - MIN_SIDE + 1));
|
||||||
|
|||||||
Reference in New Issue
Block a user