Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Variables #105

Closed
Medic-Gamingg opened this issue Jul 5, 2023 · 7 comments
Closed

Variables #105

Medic-Gamingg opened this issue Jul 5, 2023 · 7 comments

Comments

@Medic-Gamingg
Copy link

I feel as though a simple way to reference variables when inputting coordinates to make inputting repeating values or related values easier and faster, and I imagine easy to implement.

@ricktu288
Copy link
Owner

ricktu288 commented Jul 8, 2023

Do you mean to evaluate equations with named constants (which cannot be changed once evaluated) when entering the (x,y) coordinates of a control point? Or do you mean to fully parametrize the scene with a set of variables, so that you can adjust the variables and see the corresponding change?

The former is relatively easy to implement, while the latter is very difficult. It would be helpful if you could describe in more details your specific need.

Also note that some of the existing features, such as the handle (see the "Group, rotate, or scale object" section in the popup of the "Help" button), may provide some of the automation you need. For now, you may also consider using a Python script to generate the scene, as in https://phydemo.app/ray-optics/gallery/chaff-countermeasure.

@Medic-Gamingg
Copy link
Author

My intention was the latter, however now that I've further reflected on my idea it was a bit lazy of me to request such a feature, especially with the fact that I do not know much about the subject of geometric optics, meaning my idea could be near useless whether it be from a lack of need or from the need already being satisfied by something else, I apologize for opening an issue on this and in the future I will put in more consideration before opening issues.

@Medic-Gamingg Medic-Gamingg closed this as not planned Won't fix, can't repro, duplicate, stale Jul 11, 2023
@ricktu288
Copy link
Owner

ricktu288 commented Jul 22, 2023

This is actually a good feature request, and you are not the first one to request this. Actually, at least 15 items in the Gallery would be benefitted by this feature, and I have considered it seriously before.

The only problem is that the implementation is highly nontrivial, and there are several very different possible approaches, such that once decided, it will be impractical to change to another. I need to know that what the users need in order to decide which approach is the best, so it is still a good idea if you can provide your original thought. Note that this app is designed for educational purpose, so suggestions from people who do not know much about geometric optics is also valuable (compare https://www.desmos.com/, an educational-purpose graphing calculator in which almost everything is parametrizable).

Also, I will keep this issue open for discussion, since there have been other people suggesting this privately before.

Note that, however, this feature is not expected to be implemented in the near future due to its difficulty.

@ricktu288 ricktu288 reopened this Jul 22, 2023
@gbonfi
Copy link

gbonfi commented Jul 26, 2023

Thanks for reopening it. It can also come in handy to me.
I'd like to check how light propagates through a long light guide with dimples on one side. Since the dimples are all equal in size (length and depth) a variable can help to change one value, e.g. depth, to modify the shape.
At the moment I create a small section and then duplicate it many times, but if I need to change depth (so the y value) I need to replicate the procedure, while with a variable z=.... I could just change that.

@ricktu288
Copy link
Owner

ricktu288 commented Jul 29, 2023

Depending on the shape of the dimples, it looks like this automation you are describing may be possible with the handle (the "Group, rotate, or scale object" section in the popup of the "Help" button), such as clicking all the tip points of the dimples, and then move it with the handle.

Still, in the general case, the parametrization/variable feature is still required. And actually also I am thinking about the "list" feature which should work together with the variable feature, so that you don't even need to replicate that a lot of things in the beginning, and the number of replication is also an adjustable variable. In Desmos, it is very simple to achieve this.

圖片

And I have been considering to implement this also in ray-optics. But that is the most difficult part. There are actually relatively simple (but still quite difficult) approaches to implement the "variable", but then it will not allow the implementation of "list". My current thought is to use an approach that will allow these two features together.

@ricktu288
Copy link
Owner

ricktu288 commented Jul 29, 2023

Also, the main difficulty to implement this is to create the proper user interface. If you don't need a full user interface (such as you need to first edit the scene by editing the JSON code directly, but then the variables can still be adjusted in UI with sliders, and non-parametrized object can be created and edited in the UI as usual), then it is actually not that difficult, and may be done in the near future.

But without the full UI, I do not know how many people would be benefitted by this. I do not know what fraction of the users of this app is comfortable editing JSON code directly.

@ricktu288
Copy link
Owner

Recently, similar feature requests has been suggested two more times from private emails. One of the suggestion is to use a desmos-like equation sidebar approach, where the user can add objects by typing an equation, such as

C_1 = glass(circle[p, r],gradient[f(x), o])

to create a glass gradient index circle with boundary origin p, radius r, and absolute origin o.

This has a relatively simple implementation without the need to modify a lot of core code (as opposed to previously-proposed approach). We just need to treat the list of equations as a "scene-builder" outside of the existing scene editor UI, and every time the user modifies some variables or equations are modified, just "recompile" those variable/equations into the JSON object of the scene in the original format readable by the core simulator. Also, we do not need to implement all the possible features (as equations) at once, as one can still add objects in the old way in the editor (without appearing in the sidebar).

@ricktu288 ricktu288 mentioned this issue Mar 7, 2024
Repository owner locked and limited conversation to collaborators Apr 16, 2024
@ricktu288 ricktu288 converted this issue into discussion #141 Apr 16, 2024

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants