Using drawpoint in 3d axes

3 ビュー (過去 30 日間)
Sebastian
Sebastian 2025 年 1 月 24 日
編集済み: Matt J 2025 年 1 月 25 日
Hello,
I have a program that plots the electrostatic potential created by n electrons confined to a sphere. What I'd like to be able to do is grab one of those electrons and move it in the figure to see how the potential changes. What I've been able to do is project everything from the surface of the sphere onto 2D axes and use drawpoint to get the interactivity I want. However, I'm a little annoyed by the distortions inherent in the projection so before I go and add a bunch of other functionality I have in mind I want to see if I can get the interactivity while having everything remain on the sphere.
One strange thing is that while drawpoint will still create a Point object in 3D axes (constrained to z=0), it's motion is distorted: upon clicking the point, it jumps away and will move as if constrained to a line parallel to the x- or y-axes. Once the cursor gets far enough away, however, its motion does follow the cursor, just with a constant offset. The magnitude of that offset is a function of the viewing angle: when looking straight down or up the point moves as expected, but a low angle makes the point get very confused.
The fact that the point is always on the xy-plane isn't necessarily a deal-breaker, though I can already think of several issues. The bigger issue is of course the strange distorted motion. I assume there's nothing I can really do to fix that, so my question is whether there might be a different way to achieve the same end - some sort of callback on a scatterplot that would update the coordinates based on the mouse position?
If not, I do have an idea for a compromise, but I figured this was interesting enough to ask.
Thanks!
  1 件のコメント
Matt J
Matt J 2025 年 1 月 24 日
編集済み: Matt J 2025 年 1 月 24 日
I don't find that it is constrained to z=0, but rather that it will be projected onto any one of the edge planes or mid-planes of the axis box, depending on where the pointer is positioned. I don't know if there is any documentation about this rule, but it has to map to some 2D sub-region of the axis, because an image.roi.point object only has 2 position coordinates.

サインインしてコメントする。

採用された回答

Matt J
Matt J 2025 年 1 月 24 日
編集済み: Matt J 2025 年 1 月 24 日
You cannot place a 3D point using a drawing object that has only 2 degrees of freedom. Probably the better approach is to use the ButtonDownFcn of the 3D axis to detect mouse clicks. The CurrentPoint property of a mouse-click event will give the coordinates of a line that passes through the mouse position and intersects the front and back planes of the axis box.
This defines a line segment through the 3D space. You can do a calculation to see where this line intersects the spherical surface (or some other 2D-3D mapping rule of your choice) and then plot() a 3D point there.

その他の回答 (1 件)

Matt J
Matt J 2025 年 1 月 25 日
編集済み: Matt J 2025 年 1 月 25 日
Another approach is to make a custom app, with controls for the position of the electron.

カテゴリ

Help Center および File ExchangeLighting, Transparency, and Shading についてさらに検索

製品


リリース

R2024b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by