progress with aligning graph lines

This commit is contained in:
2025-07-10 22:48:34 +01:00
parent 3fe3aa1d4d
commit cda90e3f44
4 changed files with 19 additions and 53 deletions

View File

@@ -5,35 +5,31 @@ end
structure GraphLines :> GRAPH_LINES =
struct
fun toNdc (cur, half) = (cur - half) / half
fun helpGenGraphLinesX (pos, xClickPoints, yClickPoints, acc,
windowWidth, windowHeight) =
if pos = Vector.length xClickPoints then
Vector.concat acc
else
let
val halfWidth = windowHeight div 2
val halfWidth = Real32.fromInt halfWidth
val halfHeight = windowHeight div 2
val halfHeight = Real32.fromInt halfHeight
val halfWidth = Real32.fromInt (windowWidth div 2)
val halfHeight = Real32.fromInt (windowHeight div 2)
val curX = Vector.sub (xClickPoints, pos)
val curYNdc = toNdc (curX, halfWidth)
val curXNdc = (curX - halfWidth) / halfWidth
val minY = Vector.sub (xClickPoints, 0)
val minY = toNdc (minY, halfWidth)
val minY = (~(minY - halfHeight)) / halfHeight
val maxY = Vector.sub (xClickPoints, Vector.length xClickPoints - 1)
val maxY = toNdc (maxY, halfWidth)
val maxY = (~(maxY - halfHeight)) /halfHeight
val acc =
#[ curYNdc - 0.001, minY
, curYNdc + 0.001, minY
, curYNdc + 0.001, maxY
#[ curXNdc - 0.001, minY
, curXNdc + 0.001, minY
, curXNdc + 0.001, maxY
, curYNdc + 0.001, maxY
, curYNdc - 0.001, maxY
, curYNdc - 0.001, minY
, curXNdc + 0.001, maxY
, curXNdc - 0.001, maxY
, curXNdc - 0.001, minY
] :: acc
in
helpGenGraphLinesX
@@ -52,12 +48,14 @@ struct
val halfHeight = Real32.fromInt halfHeight
val curY = Vector.sub (yClickPoints, pos)
val curYNdc = toNdc (curY, halfHeight)
val curYNdc =(~(curY - halfHeight)) / halfHeight
val minX = Vector.sub (xClickPoints, 0)
val minX = toNdc (minX, halfWidth)
val minX = (minX - halfWidth) / halfWidth
val maxX = Vector.sub (xClickPoints, Vector.length xClickPoints - 1)
val maxX = toNdc (maxX, halfWidth)
val _ = print ("maxX = " ^ Real32.toString maxX ^ "\n")
val maxX = (maxX - halfWidth) / halfWidth
val acc =
#[ minX, curYNdc - 0.001