#29206 closed defect (duplicate)

3d vectors do not plot correctly in threejs

Reported by: was Owned by:
Priority: minor Milestone: sage-duplicate/invalid/wontfix
Component: graphics Keywords:
Cc: paulmasson, kcrisman Merged in:
Authors: Reviewers: Paul Masson, Karl-Dieter Crisman
Report Upstream: N/A Work issues:
Branch: Commit:
Dependencies: #29227 Stopgaps:

Status badges

Description


Attachments (2)

2020-02-15 10_10_25-Support and Testing - CoCalc.png (153.1 KB) - added by was 14 months ago.
2020-02-15 10_10_37-.png (233.6 KB) - added by was 14 months ago.

Download all attachments as: .zip

Change History (16)

comment:1 Changed 14 months ago by was

REPORTED BY: Ingo Dahn <ingodahn@…>

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

Changed 14 months ago by was

comment:2 Changed 14 months ago by egourgoulhon

  • Cc paulmasson added

comment:3 Changed 14 months ago by kcrisman

  • Cc kcrisman added

comment:4 Changed 14 months ago by kcrisman

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.

comment:5 follow-up: Changed 14 months ago by 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).

comment:6 in reply to: ↑ 5 ; follow-up: Changed 14 months ago by paulmasson

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.

comment:7 in reply to: ↑ 6 Changed 14 months ago by kcrisman

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.)

comment:8 Changed 14 months ago by kcrisman

  • Summary changed from 3d vectors no longer plot correctly (broken from sage-8.9 to sage-9.0) to 3d vectors do not plot correctly in threejs

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

comment:9 Changed 14 months ago by kcrisman

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.

comment:10 follow-up: Changed 13 months ago by paulmasson

  • Dependencies set to #29227

Will be fixed by #29227

comment:11 in reply to: ↑ 10 Changed 13 months ago by kcrisman

  • Milestone changed from sage-9.1 to sage-duplicate/invalid/wontfix
  • Status changed from new to needs_review

Will be fixed by #29227

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

comment:12 Changed 13 months ago by paulmasson

  • Reviewers set to Paul Masson
  • Status changed from needs_review to positive_review

comment:13 Changed 13 months ago by kcrisman

  • Reviewers changed from Paul Masson to Paul Masson, Karl-Dieter Crisman

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

comment:14 Changed 13 months ago by chapoton

  • Resolution set to duplicate
  • Status changed from positive_review to closed
Note: See TracTickets for help on using tickets.