jzy3d-api
jzy3d-api copied to clipboard
ViewPositionMode.FREE does not allow complete rotations
@jzy3d, Currently, org.jzy3d.plot3d.rendering.view.modes.FREE, does not allow Full 360 (complete) rotations across the 3 axes. There are certain view points that remain restricted. Is it possible to remove the restrictions in place, at least when no axes are being displayed?
Hi @tferr , the intended behaviour is to halt rotation along elevation axis (in polar coordinates) as long as one reaches the top or bottom point. Maybe the name "FREE" is not ideal then.
This behaviour is implemented here.
The best would be to modify this, add a new ViewMode and bypass the clamping for the new profile you want to introduce.
If this sounds like a too long path, you can override this without changing the framework. You simply have to override the View class that your chart uses (probably not View itself but rather AWTView), and then extend the newView() method of the factory you are using (probably AWTChartFactory) to instanciate your own View.
I like the proposal, so I would love you contribute if we can agree on naming things properly :)
thanks for the quick reply. Glad to hear it is possible. I will look first into extending newView(). If things work OK, i will follow up with a PR. What about keeping FREE, and naming the new view UNCONSTRAINED?
Yes, keeping FREE is ideal for me. I wouldn't have find a better name for your use case :)
@jzy3d, Overriding setViewPoint() works for the most part:
public void setViewPoint(Coord3d polar, boolean updateView) {
viewpoint = polar;
//viewpoint.y = viewpoint.y < -PI_div2 ? -PI_div2 : viewpoint.y;
//viewpoint.y = viewpoint.y > PI_div2 ? PI_div2 : viewpoint.y;
if (updateView)
shoot();
fireViewPointChangedEvent(new ViewPointChangedEvent(this, polar));
}
But the behavior is not yet fully unconstrained. There is still a 'tipping point' along the rotation axis. Take e.g. this example:
Rotating in the direction depicted on the left works as expected only until a certain point, then, suddenly, the view snaps to a mirrored point of view (right). Where is this behavior implemented? I saw a couple of "cameraUp" methods. Are these relevant?
Hi, that would be more easy to understand with a video - note that github issues support uploading short .mov files (I can make 10s or so with small chart). But I think I understand your point. Do you know at which point exactly does the jump occurs?
The cartesian Camera parameters are
- target : the center of the axis cube
- eye : the position of the camera
- up : the direction of the top of the camera. To my memory, my experience long time ago was that a positive z value for this vector will lead to looking "normally" while a negative value will lead to looking upside down.
If you look at the computeCameraUp last line, you see that I always set to "normal" camera direction.
protected Coord3d computeCameraUp(Coord3d viewpoint) {
if (Math.abs(viewpoint.y) == PI_div2) { // handle on top
...
} else {
return new Coord3d(0, 0, 1); // use z axis as up vector, if not on top
}
this looks qui consistent with the "flip" you observe.
If that is true, some ideas/direction for this
- remember how many time you crossed top (PI/2) and bottom (-PI/2) elevation in order to choose +1 or -1.
- reading Camera.side implementation might be instructive to do this (not sure, just an idea).
Hi, have you been able to address this point? I will probably make a release version in the coming weeks, so it may be a good time to include this if you have been able to fully implement it.
Hi @tferr , I just would like to warn you that the master branch has changes on the View class (which deal with 2D charts support, you may be interested!). I could help you build this feature if you can fund it :)
@jzy3d, Unfortunately, I ran out of time and was not able to progress much.
I could help you build this feature if you can fund it :)
That would be great. Unfortunately, we are not in a position to do so. At least not right now. All of our software work is volunteer and everything we do is open source. We just started an initiative to aid open source projects developed in house. Perhaps a future application to that program would allow for it. How is jzy3d funded?
Jzy3D is used in commercial applications that sometime require enhancements involving funded collaborations. This happened long time after creating and improving the framework as well as helping users on the forum for free.
I recently enabled Github sponsoring. I rather get funds from developers willing to reward me for the open work but this also allows providing "buttons" for short term help.
@tferr this improvement led me to make the View code more readable when thinking about viewpoints. Maybe reading the related PR can help you on the topic discussed here.