antimony icon indicating copy to clipboard operation
antimony copied to clipboard

Functions for variable connection.

Open mikea opened this issue 10 years ago • 10 comments

To keep things centered in the model I'd like to specify a function for a wire (e.g. x / 2)

mikea avatar May 30 '15 01:05 mikea

+1

I was doing the screwdriver demo and I wanted this for the inserts (eg, extrude from -radius to +xmax).

AstraLuma avatar May 30 '15 01:05 AstraLuma

Interesting. What do you see this looking like in the UI? I could imagine a smaller text box midway through the connection with a single expression that's evaluated (maybe using _ as the input variable).

mkeeter avatar May 30 '15 16:05 mkeeter

Maybe just a node with a number input (x, a) and a number output (y, b), but no shapes?

AstraLuma avatar May 30 '15 18:05 AstraLuma

That's already pretty easy with a custom script, something like

title("/2")
input("a", float)
output("b", a/2)

Does that do what you're asking?

Workflows vary from person to person, but when designing anything interesting, I end up spending a lot of time customizing the pre-existing nodes by editing their scripts (rather than trying to find ones that do exactly what I need and connecting them).

mkeeter avatar May 30 '15 18:05 mkeeter

Yeah, that works. But it'd be nice if I could have a node like

a 2
b -a

So that simple one-line expressions don't involve writing a full node.

AstraLuma avatar May 30 '15 19:05 AstraLuma

I solved it this way:

title("Multiply")
input("a", float)
input("mul", float)

output("b", a*mul)

this allows me to set mul to -1 for b = -a and 0.5 for b = a/2

Salandora avatar May 31 '15 00:05 Salandora

I found myself wanting this too. Treat constants, not just shapes, as data in the DAG.

mgold avatar May 31 '15 04:05 mgold

This is how I imagine this should be handled in the UI:

screenshot_2015-06-02_12-23-20

Expressions like that are already evaluated correctly. All thats needed is to draw the connection between the nodes and highlight the names of the variables.

Conceivably, this would also allow you to have multiple outputs feeding into the same input. These would just be represented as different variables in the expression.

unlimitedbacon avatar Jun 02 '15 19:06 unlimitedbacon

Hm. Making node reference more prominent would certainly solve the problems described here, and drawing lines would make the connection more obvious.

The way this doesn't solve the problem is if the same equation is used in more than one place in the drawing, but that can be remedied with a simple "constant" block with 1 float input and no outputs.

(As a nitpick, maybe draw them in a different style (thinner, dashed, gray) so that it's obvious to the user that this is an indirect link and non-interactive.)

AstraLuma avatar Jun 02 '15 20:06 AstraLuma

+1

jmangas avatar Jun 08 '15 13:06 jmangas