cadCAD-org / cadcad-ri

The Reference Implementation
https://cadcad.org
BSD 2-Clause "Simplified" License
18 stars 10 forks source link

[FEATURE] Support Multi-Input Blocks #36

Open mzargham opened 1 year ago

mzargham commented 1 year ago

I would like the following to be a valid block


@space
class CartesianPlane:
    x:float
    y:float

@space
class Particle:
    pos:CartesianPlane
    vel:CartesianPlane

@block
def particleIntegrator(state: Point[Particle], input: Point[CartesianPlane])-> Point[Particle]:
    #input is acceleration
    #output is the new particle state
    output = deepcopy(state)

    output['pos']['x']  += state['particle']['vel']['x']
    output['pos']['y']  += state['particle']['vel']['y']

    output['vel']['x']  += input['x']
    output['vel']['y']  += input['y']

    return output

Additional context I am working on the Cat & Laser pointer demo, and aiming to make the model as simple as possible. The most natural view of the systems is the below, which requires particle integrator (twice!) which requires 2 inputs to make sense. Tag - Page 5