Code: Alles auswählen
; f(x) = (2*p1 - 2*p2 + t1 + t2) * x^3 + (3*p2 - 3*p1 - 2*t1 - t2) * x² + t1 * x + p1
;
; p1 = f(0) - entspricht der y-Koordinate des linken Control-Points
; p2 = f(1) - entspricht der y-Koordinate des rechten Control-Points
; t1 : Anstieg der Tangente in p1 = (y2 - y1) / (x2 - x1)
; t2 : Anstieg der Tangente in p2 = (y3 - y2) / (x3 - x2)
; t[n] = (y[n+1] - y[n]) / (x[n+1] - x[n])
Define.f in
Macro AddPnt()
AddElement(Pnt())
Read Pnt()\x
Read Pnt()\y
EndMacro
Macro t(n)
(PntAr(n+1)\y-PntAr(n)\y)/(PntAr(n+1)\x-PntAr(n)\x)
EndMacro
Macro f(x)
in = x-Int(x)
p1 = PntAr(Int(x))\y
p2 = PntAr(Int(x)+1)\y
t1 = t(Int(x)) : Debug t1
t2 = t(Int(x)+1) : Debug t2
Debug ((2*p1 - 2*p2 + t1 + t2) * Pow(in,3) + (3*p2 - 3*p1 - 2*t1 - t2) * Pow(in,2) + t1 * in + p1)
EndMacro
NewList Pnt.Point()
DataSection
TerrainData:
Data.l 0, 100, 1, 103, 2, 106, 3, 112, 4, 116, 5, 119, 6, 121, 7, 121, 8, 122, 9, 124, 10, 123, 11, 119, 12, 117, 13, 120, 14, 123, 15, 125, 16, 123, 17, 115, 18, 109, 19, 104, 20, 99, 21, 95, 22, 92, 23, 89, 24, 87, 25, 85, 26, 83, 27, 80, 28, 77, 29, 77, 30, 74, 31, 69, 32, 65, 33, 66, 34, 69, 35, 74, 36, 79, 37, 82, 38, 83, 39, 83, 40, 85, 41, 91, 42, 96, 43, 101, 44, 106, 45, 107, 46, 106, 47, 106, 48, 106, 49, 107, 50, 108, 51, 109, 52, 111, 53, 111, 54, 110, 55, 110, 56, 111, 57, 110, 58, 111, 59, 113, 60, 116, 61, 118, 62, 118, 63, 118, 64, 120, 65, 122, 66, 122, 67, 123, 68, 122, 69, 118, 70, 114, 71, 111, 72, 108, 73, 105, 74, 100, 75, 94, 76, 89, 77, 86, 78, 85, 79, 83, 80, 81, 81, 78, 82, 74, 83, 70, 84, 66, 85, 63, 86, 58, 87, 52, 88, 48, 89, 44, 90, 41, 91, 39, 92, 36, 93, 33, 94, 30, 95, 27, 96, 24, 97, 24, 98, 25, 99, 28, 100, 30, 101, 34, 102, 38, 103, 42, 104, 45, 105, 48, 106, 50, 107, 52, 108, 52, 109, 50, 110, 48, 111, 50, 112, 51, 113, 52, 114, 53, 115, 55, 116, 56, 117, 57, 118, 59, 119, 59, 120, 58, 121, 56, 122, 55, 123, 53, 124, 51, 125, 48, 126, 46, 127, 46, 128, 48, 129, 50, 130, 51, 131, 50, 132, 49, 133, 52, 134, 55, 135, 58, 136, 60, 137, 59, 138, 57, 139, 56, 140, 55, 141, 55, 142, 55, 143, 53, 144, 51, 145, 50, 146, 50, 147, 50, 148, 50, 149, 49, 150, 47, 151, 44, 152, 43, 153, 41, 154, 39, 155, 38, 156, 37, 157, 36, 158, 34, 159, 32, 160, 32, 161, 32, 162, 32, 163, 31, 164, 29, 165, 30, 166, 32, 167, 33, 168, 33, 169, 32, 170, 32, 171, 34, 172, 35, 173, 35, 174, 32, 175, 29, 176, 26, 177, 23, 178, 19, 179, 15, 180, 12, 181, 9, 182, 7, 183, 5, 184, 3, 185, 2, 186, 1, 187, 0, 188, 0, 189, 0, 190, 0, 191, 0, 192, 0, 193, 0, 194, 0, 195, 0, 196, 0, 197, 0, 198, 0, 199, 0, 200, 0, 201, 0, 202, 0, 203, 2, 204, 5, 205, 7, 206, 7, 207, 7, 208, 7, 209, 8, 210, 9, 211, 9, 212, 10, 213, 11, 214, 12, 215, 15, 216, 19, 217, 24, 218, 30, 219, 40, 220, 49, 221, 59, 222, 68, 223, 76, 224, 81, 225, 87, 226, 92, 227, 97, 228, 102, 229, 109, 230, 115, 231, 119, 232, 121, 233, 122, 234, 119, 235, 119, 236, 123, 237, 125, 238, 124, 239, 123, 240, 124, 241, 123, 242, 120, 243, 114, 244, 107, 245, 101, 246, 98, 247, 97, 248, 96, 249, 95, 250, 98, 251, 102, 252, 104, 253, 103, 254, 102, 255, 102, 256, 101
EndDataSection
Restore TerrainData
For i = 0 To 256
AddPnt()
Next
c = CountList(Pnt())
Dim PntAr.Point(c)
ForEach Pnt()
PntAr(ListIndex(Pnt()))\x = Pnt()\x
PntAr(ListIndex(Pnt()))\y = Pnt()\y
Next
f(2)