octave-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Octave-bug-tracker] [bug #47185] Improved code attached for quiver3 and


From: Dave Goel
Subject: [Octave-bug-tracker] [bug #47185] Improved code attached for quiver3 and __quiver__ , making arrowheads actually visible:
Date: Fri, 26 Feb 2016 15:52:59 +0000
User-agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/48.0.2564.116 Safari/537.36

Follow-up Comment #3, bug #47185 (project octave):

Hi again Lachlan Andrew,

Thanks for responding. 

(1) My bad. I have added extensive commentary now, re-tested everything, and
am pasting the new code. It should be much more self-explanatory. 

(2) The hg part is a much steeper learning curve for me and I have never used
hg before. I have to run for an interview, but I shall put this on my todo
list. 

Here's the code with better commentary:

In the if(is3d) section, this code replaces this one command:


    

      ## h2 = plot3 ([xarrw1.'; xend.'; xarrw2.'; NaN(1, length (x))](:),
      ##             [yarrw1.'; yend.'; yarrw2.'; NaN(1, length (y))](:),
      ##             [zarrw1.'; zend.'; zarrw2.'; NaN(1, length (z))](:),
      ##             "linestyle", ls, "color", lc, "parent", hg);


by:



    ## Octave's arrowheads for the 3d case are currently a massive hack. In
principle, arrowheads are a nice round cone around the arrow. But, octave's
3-D arrows were
      ## hitherto the usual 2-D arrowhead.  This has several problems: (1) The
plane in which arrowhead lies, seems, for all intents and purposes, arbitrary
for every
      ## arrow. That confuses the user who tries to glean what's the deeper
meaning about the plane. (2) Often, this plane is "into the page" plane,
rendering the
      ## arrowhead completely invisible.

      ## The advantage of the hack, however, is that it's probably much faster
than drawing a nice round cone. So, in keeping with the hack, we rectify the
problem
      ## thusly: We introduce 4 arrowheads instead of 2. That pretty much
guarantees at least two of them shall be visible from any angle, and the user
shall always see
      ## an arrowhead. It is still not a nice round cone, but is much closer
to the concept.
      ## This new code seems to take about 4 times longer than the preceding
code. 
      
      
      xarrw3=xarrw1; yarrw3=yarrw2; ## Create arrowhead 3: use x from 1 and y
from 2.
      xarrw4=xarrw2; yarrw4=yarrw1; ## Create arrowhead 4: Use x from 2 and y
from 1.
      ## Make temporary larger vectors to enable plotting within one command
that can continue to be turned off or on using buttons.
      ## The arrowhead goes from arrowhead 1 to endpoint to arrowhead 2, and
separately from arrowhead 3 to endpoint to arrowhead 4.
      ## But, we shall seek to do these all in one go, so we combine them
vertically. We do that so that the button commands continue to work. And, hold
status doesn't intervene.
      
      xarrw13=[xarrw1(:); xarrw3(:)];  ## Combine arrows 1 and 3 vertically,
call it 13. 
      yarrw13=[yarrw1(:); yarrw3(:)]; ##
      zarrw13=[zarrw1(:); zarrw1(:)];

      xarrw24=[xarrw2(:); xarrw4(:)]; ## Combine  arrows 2 and 4 vertically,
calli it 24.
      yarrw24=[yarrw2(:); yarrw4(:)];
      zarrw24=[zarrw2(:); zarrw2(:)];

      nans2=NaN(1,2*length(xend)); ## Nans are needed to "lift the pen" when
drawing. Double the nans since we now have double the arrowheads. 

      xend11=[xend(:); xend(:)];  ## Duplicate xend to plot double the number
of arrows in one command. 
      yend11=[yend(:); yend(:)];
      zend11=[zend(:); zend(:)];



      h2 = plot3 ( ...
                   [xarrw13(:), xend11(:),  xarrw24(:), nans2(:)]' ,
                   [yarrw13(:), yend11(:),  yarrw24(:), nans2(:)]' ,
                   [zarrw13(:), zend11(:),  zarrw24(:), nans2(:)]' ,
                   "linestyle", ls, "color", lc, "parent", hg);






    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/bugs/?47185>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.gnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]