aboutsummaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
2024-07-26Functioning main loop which draws number lines and iterationsAryadev Chavali
Pretty cool!
2024-07-26Function to draw the complete number lineAryadev Chavali
Draws a guide line, computes bounds (which we should defer), draws all nodes in the tree then draws the bounds.
2024-07-26Make draw_node_number_line non recursiveAryadev Chavali
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-26recursive function to draw tree in a number lineAryadev Chavali
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-26Helper to draw a fraction as text at point (x, y)Aryadev Chavali
2024-07-26Helper to convert a value in (min, max) to an equivalent in (0, width)Aryadev Chavali
2024-07-26Helpers to get the rightmost and leftmost nodeAryadev Chavali
This, due to the properties of a cw tree, will be the largest and smallest fraction of the tree.
2024-07-26Define some constants and include a ton of stuffAryadev Chavali
2024-07-26NodeAllocator can now get nodes by value or by referenceAryadev Chavali
Abstracting the interface more, such that callers can use functions rather than accessing internals directly, allows me to refactor the allocator without having to do a ton of edits all across the source tree.
2024-07-26Changed from int64_t to optional<word_t> for pointers in NodeAryadev Chavali
2024-07-26Make window in RaylibAryadev Chavali
2024-07-26Ignore TAGSAryadev Chavali
2024-07-26`iterate` now computes highest value fraction it generated.Aryadev Chavali
Not very useful, but isn't a massive performance waster (I think) and it will be useful when thinking about colour schemes in graphics.
2024-07-26Rework MAX macro to use `<` operatorAryadev Chavali
MAX now works with Fraction's
2024-07-26Introduce normalised value in fraction classAryadev Chavali
Bit of a cheat but it would allow us to do some interesting graphical stuff later.
2024-07-26Add numerics to build systemAryadev Chavali
Successfully compiles and runs!
2024-07-26Change main to use new numerics module.Aryadev Chavali
2024-07-26Implemented numerics in numerics.cppAryadev Chavali
Simple implementation, few refactors from the main.cpp version based on API changes.
2024-07-26Rework node constructor and general procedure APIAryadev Chavali
Node constructor is now completely default constructed i.e. no constructor arguments required. The iterate function takes the queue by reference, so it can update the caller's state. Finally, to_string for a Node now uses the node allocator and an index to print out trees. Seems simpler and more in line with the current implementation.
2024-07-26Made header file for a separate numerics fileAryadev Chavali
Separates the (basically) completed cw_tree implementation in a separate module so we can spend time implementing graphics in main. NOTE: nodes are now generated from a node allocator, which just wraps around the vector. We also take an allocator and queue by reference in the iterate procedure now.
2024-07-26A simple test, iterating 10 times and printing out the generated treeAryadev Chavali
Seems to work!
2024-07-26Fix up indenting and empty children in to_string for nodeAryadev Chavali
2024-07-26Added to_string for NodesAryadev Chavali
Recursive implementation with proper indenting!
2024-07-26Added to_string for fractionsAryadev Chavali
2024-07-26Rework binary tree to use indexes in nodes vectorAryadev Chavali
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-26Added helper method to allocate nodes from the vector for meAryadev Chavali
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-26Queue based iteration procedureAryadev Chavali
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-26Binary tree of fractionsAryadev Chavali
Will be used in creating the cw tree.
2024-07-26Simplify at constructor in FractionAryadev Chavali
Let's just deal with simplified stuff anyway?
2024-07-26Added comparators to Fraction structAryadev Chavali
2024-07-26Extracted gcd algorithm into its own functionAryadev Chavali
2024-07-26Simple fraction structureAryadev Chavali
Holds numerator and denominator. Can self simplify, but not automatically.
2024-07-26Hello, world!Aryadev Chavali