Aryadev Chavali
7e801df280
no more numerics
2025-12-12 03:55:43 +00:00
Aryadev Chavali
00858cf74f
Rewrite main to draw based on our new state/draw_state
...
Arranges a thread set, draws based on draw_state. No need to lock the
mutex since drawing should only require reading. Still has a timer in
case we need to do timed checks.
2025-11-28 17:24:33 +00:00
Aryadev Chavali
3e065e50a9
Disable previous work
...
We're going to rewrite this
2025-11-28 17:24:12 +00:00
Aryadev Chavali
9d8215bd45
Adjusted copyright template for code files
2025-11-27 00:39:01 +00:00
Aryadev Chavali
15b3f9fb12
Add some notes
2025-11-17 01:22:45 +00:00
Aryadev Chavali
8a2214f2fb
Simulation only runs if SPACE is held or PERIOD is pressed.
...
KEY_SPACE, held, will keep the simulation running.
KEY_PERIOD will do exactly one iteration per press.
2025-11-17 01:10:46 +00:00
Aryadev Chavali
564bac363f
Clean up and use the right initial fraction for CW tree
2024-07-27 02:20:31 +01:00
Aryadev Chavali
76d407ae1b
Added timer to automatically do iterations
...
Looks very cool.
2024-07-27 01:44:07 +01:00
Aryadev Chavali
f1b878c991
Left and right fractions are now drawn at the top with counter
2024-07-27 01:35:43 +01:00
Aryadev Chavali
feabcf24a0
Draw the three iteration nodes in special colours
...
green for the centre, blue for the new nodes generated.
2024-07-27 01:25:27 +01:00
Aryadev Chavali
32314708d5
Made nested Bounds structure to encapsulate work with bounds
...
Looks a bit nicer, probably increases padding but whatever.
2024-07-26 21:58:53 +01:00
Aryadev Chavali
bb6ded706f
Move all functions and state into one struct
...
One God structure which will hold all the necessary state, ensuring I
only need to compute stuff like bounds at most once, better than
computing it on every draw (which is WAY slower at scale).
2024-07-26 21:44:08 +01:00
Aryadev Chavali
0eaa851114
Increase font size, other small changes
2024-07-26 21:08:59 +01:00
Aryadev Chavali
2ddf2d0b48
Clean up count drawing logic a bit, add iterations to the count text
2024-07-26 21:07:18 +01:00
Aryadev Chavali
edc0383132
Added counter to draw loop to show the amount of nodes computed
2024-07-26 21:03:56 +01:00
Aryadev Chavali
a614626b21
Functioning main loop which draws number lines and iterations
...
Pretty cool!
2024-07-26 21:02:24 +01:00
Aryadev Chavali
950706fdaf
Function to draw the complete number line
...
Draws a guide line, computes bounds (which we should defer), draws all
nodes in the tree then draws the bounds.
2024-07-26 21:00:34 +01:00
Aryadev Chavali
89fd812981
Make draw_node_number_line non recursive
...
Using a stack or queue, we can replace a function recursive tree
traversal with a single call. A stack would make it a DFS while a
queue would be a BFS. Since there's only ever two children, and at
high iteration counts we're getting quite large depth, it would be
best to do a DFS, hence the stack.
2024-07-26 20:53:54 +01:00
Aryadev Chavali
01468f793f
recursive function to draw tree in a number line
...
Draws the current node by converting its norm value (which is in
(lower, upper)) to a screen value, drawing a line there.
It then recurs on the children of the node.
2024-07-26 20:46:39 +01:00
Aryadev Chavali
3a911db312
Helper to draw a fraction as text at point (x, y)
2024-07-26 20:46:34 +01:00
Aryadev Chavali
99d3794749
Helper to convert a value in (min, max) to an equivalent in (0, width)
2024-07-26 20:46:34 +01:00
Aryadev Chavali
096c1089ca
Helpers to get the rightmost and leftmost node
...
This, due to the properties of a cw tree, will be the largest and
smallest fraction of the tree.
2024-07-26 20:46:34 +01:00
Aryadev Chavali
08e890ee4a
Define some constants and include a ton of stuff
2024-07-26 20:46:34 +01:00
Aryadev Chavali
c96c4630d5
Make window in Raylib
2024-07-26 03:17:09 +01:00
Aryadev Chavali
6a6ed5a545
Change main to use new numerics module.
2024-07-26 02:59:38 +01:00
Aryadev Chavali
9ea4341a80
A simple test, iterating 10 times and printing out the generated tree
...
Seems to work!
2024-07-26 02:54:02 +01:00
Aryadev Chavali
93d3ce89cc
Fix up indenting and empty children in to_string for node
2024-07-26 02:54:02 +01:00
Aryadev Chavali
6dfd820772
Added to_string for Nodes
...
Recursive implementation with proper indenting!
2024-07-26 02:54:02 +01:00
Aryadev Chavali
5cbdf7a045
Added to_string for fractions
2024-07-26 02:54:02 +01:00
Aryadev Chavali
aad22a1b20
Rework binary tree to use indexes in nodes vector
...
An index is a pointer, and they don't change if the vector decides to
reallocate internally unlike the bastardised pointers I was rolling up
before. This simplifies design a bit.
2024-07-26 02:54:02 +01:00
Aryadev Chavali
cb0d4f5207
Added helper method to allocate nodes from the vector for me
...
The vector acts as an arena for the nodes to be allocated from, better
and faster than allocating each child on the heap individually.
2024-07-26 02:54:02 +01:00
Aryadev Chavali
ee1cc0816a
Queue based iteration procedure
...
Pops an item off the queue and generate left and right children for it,
if those are empty. Then push those children into the queue for the
next iteration.
NOTE: Because we're using a queue, this does a breadth first
generation of the tree, which is what we want.
2024-07-26 02:54:02 +01:00
Aryadev Chavali
9769337a92
Binary tree of fractions
...
Will be used in creating the cw tree.
2024-07-26 02:54:02 +01:00
Aryadev Chavali
cc51f78d10
Simplify at constructor in Fraction
...
Let's just deal with simplified stuff anyway?
2024-07-26 02:54:02 +01:00
Aryadev Chavali
6d64f5ebac
Added comparators to Fraction struct
2024-07-26 02:54:02 +01:00
Aryadev Chavali
f64a82c538
Extracted gcd algorithm into its own function
2024-07-26 02:54:02 +01:00
Aryadev Chavali
0727126061
Simple fraction structure
...
Holds numerator and denominator. Can self simplify, but not
automatically.
2024-07-26 02:54:02 +01:00
Aryadev Chavali
6f7be667e2
Hello, world!
2024-07-26 02:54:02 +01:00