39 set(points[0], points[1], 40 points[2], points[3], 41 points[4], points[5], 42 points[6], points[7]); 43 return; 44 case 6: 45 set(points[0], points[1], 46 points[2], points[3], 47 points[4], points[5]); 48 return; 49 default: 50 throw new InternalError("Curves can only be cubic or quadratic"); 51 } 52 } 53 54 void set(float x1, float y1, 55 float x2, float y2, 56 float x3, float y3, 57 float x4, float y4) 58 { 59 ax = 3.0f * (x2 - x3) + x4 - x1; 60 ay = 3.0f * (y2 - y3) + y4 - y1; 61 bx = 3.0f * (x1 - 2.0f * x2 + x3); 62 by = 3.0f * (y1 - 2.0f * y2 + y3); 63 cx = 3.0f * (x2 - x1); 64 cy = 3.0f * (y2 - y1); 65 dx = x1; 66 dy = y1; 67 dax = 3.0f * ax; day = 3.0f * ay; 68 dbx = 2.0f * bx; dby = 2.0f * by; 69 } 70 71 void set(float x1, float y1, 72 float x2, float y2, 73 float x3, float y3) 74 { 75 ax = 0.0f; ay = 0.0f; 76 bx = x1 - 2.0f * x2 + x3; 77 by = y1 - 2.0f * y2 + y3; 78 cx = 2.0f * (x2 - x1); 79 cy = 2.0f * (y2 - y1); 80 dx = x1; 81 dy = y1; 82 dax = 0.0f; day = 0.0f; 83 dbx = 2.0f * bx; dby = 2.0f * by; 84 } 85 86 float xat(float t) { 87 return t * (t * (t * ax + bx) + cx) + dx; 88 } 89 float yat(float t) { 90 return t * (t * (t * ay + by) + cy) + dy; 91 } 92 93 float dxat(float t) { 94 return t * (t * dax + dbx) + cx; 95 } 96 97 float dyat(float t) { 98 return t * (t * day + dby) + cy; 99 } | 39 set(points[0], points[1], 40 points[2], points[3], 41 points[4], points[5], 42 points[6], points[7]); 43 return; 44 case 6: 45 set(points[0], points[1], 46 points[2], points[3], 47 points[4], points[5]); 48 return; 49 default: 50 throw new InternalError("Curves can only be cubic or quadratic"); 51 } 52 } 53 54 void set(float x1, float y1, 55 float x2, float y2, 56 float x3, float y3, 57 float x4, float y4) 58 { 59 final float dx32 = 3.0f * (x3 - x2); 60 final float dy32 = 3.0f * (y3 - y2); 61 final float dx21 = 3.0f * (x2 - x1); 62 final float dy21 = 3.0f * (y2 - y1); 63 ax = (x4 - x1) - dx32; 64 ay = (y4 - y1) - dy32; 65 bx = (dx32 - dx21); 66 by = (dy32 - dy21); 67 cx = dx21; 68 cy = dy21; 69 dx = x1; 70 dy = y1; 71 dax = 3.0f * ax; day = 3.0f * ay; 72 dbx = 2.0f * bx; dby = 2.0f * by; 73 } 74 75 void set(float x1, float y1, 76 float x2, float y2, 77 float x3, float y3) 78 { 79 final float dx21 = (x2 - x1); 80 final float dy21 = (y2 - y1); 81 ax = 0.0f; ay = 0.0f; 82 bx = (x3 - x2) - dx21; 83 by = (y3 - y2) - dy21; 84 cx = 2.0f * dx21; 85 cy = 2.0f * dy21; 86 dx = x1; 87 dy = y1; 88 dax = 0.0f; day = 0.0f; 89 dbx = 2.0f * bx; dby = 2.0f * by; 90 } 91 92 float xat(float t) { 93 return t * (t * (t * ax + bx) + cx) + dx; 94 } 95 float yat(float t) { 96 return t * (t * (t * ay + by) + cy) + dy; 97 } 98 99 float dxat(float t) { 100 return t * (t * dax + dbx) + cx; 101 } 102 103 float dyat(float t) { 104 return t * (t * day + dby) + cy; 105 } |