Gax
Simulating electricity flow in wire/component classes in a linked list like manner
While this involves physics, I don't need help with that part, but instead with passing data from chains of wires that may have multiple outputs
Currently working on a circuit simulation program. I have all the math done (for a prototype at least) working but with a few issues that I'm struggling to fix.
Here's my base wire class. It is inherited by other components, such as Resistors, LEDs a Voltage Source, etc with overriden flows, however they still pretty much use
DefaultFlow();
.
The wire state has to be reset before every flow
https://paste.mod.gg/jcdunwrniejd/0
Assuming a simple circuit with only one source
My issue
When using only one voltage source, the circuit works wonders. However issues arise when chaining two or more of them, because sadly the order where flow is computed will matter. For example assume this setup:
- Assuming wire does not connect back to Source2.
- Ignore resistance.
- Source2 has 5V and Source1 has 3V
- Source2
was instantiated after Source1
, which means it would be at an index after Source1
in a wire list
However, when iterating over the sources to start the flow, the issue starts: The wire only gets Source1
's voltage. Which means it'll have 3V instead of the expected 8V.
I have thought of finding the source that has the longest "chain" of wires/components, however this becomes flawed when Wire
connects back to Source2
, just like an expected circuit, since all sources could have the same "chain length" (imagine a 4th wire connecting back to Source2
)
Another (very bad) idea was recursively calculating the expected values for the circuit all the way up to that specific wire, but that brought a lot of issues, mainly performance ones considering these calculations happen every frame.
I'm not entirely sure what the best solution for this is, and am just looking for ideas on how to proceed or maybe find a solution using a feature I'm unaware of.11 replies
Blazor WASM in NET 8component not being recognized
I created components that are all recognized in VS2022, simply create a Razor Component, inherit ComponentBase and add the code for the component. Works fine and can use them anywhere, but now, all the sudden, i can't use any new components i create, even if i make them the exact same way i did for the ones that work, does anyone have any idea why this might be happening?
1 replies
Generating input fields for each element in an array in Blazor WASM
I'm trying to generate an input field for each element in an array, and have the input field bind that element to the array, however, no matter how i do it, it either throws an exception or doesn't bind at all.
This is basically what I have right now
Currently, it generates the input fields, but when attempting to change values, it throws an IndexOutOfRangeException
6 replies