Open Toxic-Cookie opened 3 years ago
A possible good addition to this report could be the list of operations to support, for instance would sin and cos be included (and then degree or radian version), pi, other consts and magic symbols? Like drag dropping 'prev + 1' into fields increments the previous value by one kind of thing, if 'prev' was able to exist representing the last populated field value.
How complex is this gunna get!
Here's a list of useful symbols I drummed up right quick, past the first few it's kinda a crapshoot though (hex inputs would be great though).
If a complex parser is implemented (or more time savings wise, antlr), extra operators would be free/cheap, at least in my eyes, I think the parser is the painful part.
Symbol | Operation |
---|---|
( x ) | Parentheses, for scoping rules! |
x + y | add |
x - y | negate if unary, subtract if binary |
x * y | multiply |
x / y | divide |
x % y | modulo |
x & y | binary and |
x | y | binary or |
x ^ y | binary xor |
NNNN | Base 10 value input |
0xNNNN | Hex value input |
0b0010_1111 | Binary value input |
Extra credit ops! | Symbol | Operation |
---|---|---|
sin(x) | degree sine | |
sinr(x) | radian sine | |
cos(x) | degree cosine | |
cosr(x) | radian cosine | |
exp(x, y) | X raised to Y | |
root(x, y) | y root of x | |
ln(x) | log base e of x | |
log(x) | Log base 10 of x | |
log(x, y) | Log base y of x | |
pi | constant pi | |
e | constant e |
And the two operators that go above and beyond what is sane. | Symbol | Operation |
---|---|---|
prev | The previous numeric value held by the field, this is the value reverted to if undo is done. | |
x ? y : z | good ol ternary this is mostly useful for the drag-drop style with prev |
And may more!
Thanks! This is very useful additional information for this feature! Perhaps even bitwise/bitshift operations could be supported such as (>>) and (<<).
This is something that I've considered adding for a while, but it's a bit trickier. ideally we'd use an existing expression parser/evaluator for this, because writing one from scratch can be quite time consuming, especially if you want it to handle more complex stuff.
There's a bunch out there that can be used, but a lot of them use features that would put significant constraints (e.g. no IL2CPP or other forms of AOT).
With a sufficiently complex one, this also introduces potential security exploits as it starts getting into the scripting realm, which puts more complications for the implementation.
I think using one that's relatively simple with math operations would be best here for the fields to avoid the problems above, but it's matter of finding the right library.
There are a bunch like these: https://archive.codeplex.com/?p=ncalc https://github.com/codingseb/ExpressionEvaluator https://github.com/KirillOsenkov/MathParser https://github.com/davideicardi/DynamicExpresso/ (I've already looked into this one in the past for example, it wouldn't work at all due to dependency on dynamically emitting code and some conflicts with Unity's Mono/IL2CPP in that area)
But each of them has some red flags for our usage on the surface, so I'd need to dig into them deeper.
While we're at the topic of getting inspiration from the Blender interface, another amazing feature in that is that you can drag over multiple input fields to input a value into all of those at once:
I think this could be quite useful in Neos as well. Granted it's only a minor quality of life improvement, but it's an insanely comfortable thing to use.
I think dragging values between fields as works right now may be a viable replacement for that? It's a little slower but still doesn't require typing the number again. Or are you going for something different?
Hey Everyone, Remember to try to keep feature requests limited to the context that they originally ask for or are opened for. This dragging concept is a separate request and should be opened in a separate issue.
@Earthmark this isn't dragging between fields like we have. This is editing multiple fields at the same time using a dragging gesture. You drag over 3 fields for example and then type 1, once and it enters 1 into all 3 fields. We do not have this.
Hey Everyone, Remember to try to keep feature requests limited to the context that they originally ask for or are opened for. This dragging concept is a separate request and should be opened in a separate issue.
Sorry for that, opened a new issue for my idea. (#1618)
Given the self contained nature of a math expression parser, would you allow community contributions for a library @Frooxius ?
I can see using a pre-made parsing library like antlr, or even doing a simple string split based parser being a good project for those in the community who have come to me and are interested in learning more C#. In terms of a project it's quite testable, self contained, and can have very rigid requirements. Obviously that would make it not as fast of a drop in solution, but if a library of acceptable quality was made as a community contribution would you consider it? I'm fairly confident one of the red flags is library usage, and a community made parser would score very low on that rating.
@Earthmark I'm not fully sure. If the community produced library that ticks all the right boxes that we need, then I'd use it, but doing that is a bit tricky and I'd like to avoid scenario where something gets made with a lot of effort and time, only to be rejected because it doesn't fit.
Having a more general library that's made and used by other projects is a safer bet in this case, even from the maintenance perspective. If the community library stops being updated, we'd have to take up the maintenance and do it ourselves if necessary and there might be lots of bugs that are already ironed out with existing projects.
I'm looking at this one: https://github.com/codingseb/ExpressionEvaluator
It's looking most promising so far for our use, it's relatively self contained (it's all in a single file too), doesn't really have any dependencies other than .NET Framework itself and is not too complex, while still being quite capable.
The only concerns are that it might have exploitable functionality, so that's something I'd have to poke and see how problematic it is.
Thank you for the description, I totally understand. Good luck on the investigation, and I hope it's what your hoping!
Ideally, it wouldn't just be a instantaneous calculation, but allow for expressions such as being able to calculate a function like (sqrt(2/x)^4 within the field, and allow for variable input's
Yes, this type of equation can be done in logix, but if something like this is implemented, many people will likely start using things like format (or other methods) to input variables in the fields, so it would be best to ensure the system can handle that use case from the beginning if possible, rather than having to patch it in later. Or to release it along side something similar to what is described in #2908 if it is not possible to combine the functionality in order to avoid this system being misused and possibly causing problems
+1, Often I just want to set the size or coordinate of something to a value plus or minus (and times or divided by) something else. Doing it in my head or pulling out a calculator takes more time.
Is your feature request related to a problem? Please describe.
Being able to perform math operations in value fields is a convenient feature that software such as Unity and Blender have. Neos currently does not have this feature.
Describe the solution you'd like
The ability to perform math operations in value fields. For example: If you want to double the Y position of a slot you could type in (0, 1*2, 0) and the new value would be (0, 2, 0). This becomes more handy if you quickly want to change a value without doing the math in your head.
Additional context
Before the operation:
During the operation:
After the operation: