Skip to content
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

3d vectors do not plot correctly in threejs #29206

Closed
williamstein opened this issue Feb 15, 2020 · 14 comments
Closed

3d vectors do not plot correctly in threejs #29206

williamstein opened this issue Feb 15, 2020 · 14 comments

Comments

@williamstein
Copy link
Contributor

Depends on #29227

CC: @paulmasson @kcrisman

Component: graphics

Reviewer: Paul Masson, Karl-Dieter Crisman

Issue created by migration from https://trac.sagemath.org/ticket/29206

@williamstein williamstein added this to the sage-9.1 milestone Feb 15, 2020
@williamstein
Copy link
Contributor Author

comment:1

REPORTED BY: Ingo Dahn ingodahn@gmail.com

The following code prints in sage-9.0 blue lines instead of colored vectors (with tips). In sage-8.9 the presentation is correct:

v1=vector([1,2,3])
v2=vector([4,5,6])
p1=plot(v1)
p2=plot(v2,color='red')
p1+p2

@williamstein
Copy link
Contributor Author

@kcrisman
Copy link
Member

comment:4

For what it's worth viewer="tachyon" continues to seem to be okay, and viewer="jmol" (i.e. jsmol) seems to be slightly better (though still weird) on the Sage cell server. See this Sage cell to try out all three.

@kcrisman
Copy link
Member

comment:5

Could this be a bug in the newest threejs we included (r110)? I'm not suggesting it is, but it would be worth checking out and comparing both versions in all three viewers (or any others I have forgotten existed).

@paulmasson
Copy link
Mannequin

paulmasson mannequin commented Feb 25, 2020

comment:6

Replying to @kcrisman:

Could this be a bug in the newest threejs we included (r110)? I'm not suggesting it is, but it would be worth checking out and comparing both versions in all three viewers (or any others I have forgotten existed).

This is not an issue with Three.js itself. Most objects in Sage do not have a standard JSON representation like surfaces. For points, lines, texts and vector fields I had to choose some other attribute to distinguish their types. Mathematical vectors, as opposed to arrow3d, clearly lack the selected attributes. This is likely to occur for other abstract mathematical objects.

@kcrisman
Copy link
Member

comment:7

This is not an issue with Three.js itself. Most objects in Sage do not have a standard JSON representation like surfaces.

That makes sense.

For points, lines, texts and vector fields I had to choose some other attribute to distinguish their types. Mathematical vectors, as opposed to arrow3d, clearly lack the selected attributes.

When you say, "I had to choose", I assume you mean you implemented some of the code for this - can you point to some tickets or code where you think this might have shown up? Maybe it's just as simple a problem as the move to threejs for plotting? Thanks for any useful pointers.

William, the images you posted show which version of Sage was involved, but can you tell us whether you can see which "viewer" was involved? (I can't remember when threejs became a default option for 3d viewing.)

@kcrisman
Copy link
Member

comment:8

Scratch all that - I have now been able to confirm the problem is threejs, as paulmasson's comment implied. Changing title appropriately.

@kcrisman kcrisman changed the title 3d vectors no longer plot correctly (broken from sage-8.9 to sage-9.0) 3d vectors do not plot correctly in threejs Feb 25, 2020
@kcrisman
Copy link
Member

comment:9

What I don't understand is that

if plot_type == 'arrow':
    return line3d([start, [(u+v) for u,v in zip(coords, start)]], arrow_head=True, **kwds)

is in sage/src/sage/modules/free_module_element.pyx.

Okay, the real problem is that arrow_head isn't implemented (apparently). Try this:

line3d([[0,0,0], [(u+v) for u,v in zip([1,2,1], [0,0,0])]], arrow_head=True,viewer='threejs')

If someone can give me a pointer to where line3d for threejs is implemented (I haven't been actively developing in the plot code since about when threejs was fairly experimental) I can try to track this down exactly.

@paulmasson
Copy link
Mannequin

paulmasson mannequin commented Mar 19, 2020

comment:10

Will be fixed by #29227

@paulmasson
Copy link
Mannequin

paulmasson mannequin commented Mar 19, 2020

Dependencies: #29227

@kcrisman
Copy link
Member

comment:11

Will be fixed by #29227

Agreed, this is now a dup. If you agree (as I think you do) then hit the button.

@kcrisman kcrisman removed this from the sage-9.1 milestone Mar 19, 2020
@paulmasson
Copy link
Mannequin

paulmasson mannequin commented Mar 19, 2020

Reviewer: Paul Masson

@kcrisman
Copy link
Member

comment:13

Great. Glad someone worked on it too - that is awesome. Thank you for building the infrastructure.

@kcrisman
Copy link
Member

Changed reviewer from Paul Masson to Paul Masson, Karl-Dieter Crisman

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants