Group Abstract Group Abstract

Message Boards Message Boards

0
|
12.7K Views
|
9 Replies
|
4 Total Likes
View groups...
Share
Share this post:

Force traditional XYZ axis layout while using Graphics3D?

Posted 6 years ago

While using Graphics3D I need to produce a traditional x-y-z labeled axis system. I need X, Y, and Z axis to intersect at "0", the Cartesian origin. What I get is the software interfering (perhaps it is an effort to make the graphics more readable): XYZ Not Intersecting At Origin

How do I force:

  • Axes intersect at 0;
  • X is left/right orientation;
  • Y is down/up orientation;
  • Z is out/in orientation.

EDIT: I did find AxesEdge and AxesOrigin, but have been unable to make it work as I was hoping. AxesEdge examples seem to only exist for "Automatic" or "None".

POSTED BY: Dan Stimits
9 Replies
Posted 6 years ago

Bingo! It is the offset from a corner of bounding box being different from center of bounding box which was changing things. I am going to read all I can on the bounding box.

Then I will do as you mention to add Arrow[] instead of the built in coordinate system. This makes sense. Thank you.

POSTED BY: Dan Stimits
Anonymous User
Anonymous User
Posted 6 years ago

I suggest making your own if you are still not where you need to be.

Axis can be controlled, as can be PlotRange (which tends to stabilize things not being optimally chosen, having a set plotrange). You can specify the axis options and how many tic marks to use and labeling too. But I admit there are many graphics options and what combination of these would make what you need "semi-permanent" i cannot say for sure.

Did you consider options changing? so even if you pick the lock of correct options it may not work in the future (or similarly fixing what wr considers a small change in plot options could for you be a huge burden to re-solve in another way - or even impossible). wr does "avoid doing that", but.

If it still does not work just use Arrow[] and make your own axis and optionally Line[] to make tick marks, Text[] for labels: that's all it is. Don't be afraid to make your own if it won't take long - Mathematica is made to be flexible.

POSTED BY: Anonymous User
Posted 6 years ago
POSTED BY: Dan Stimits
Posted 6 years ago
POSTED BY: Hans Milton
Posted 6 years ago
POSTED BY: Dan Stimits
Posted 6 years ago

Prior to adding the Cone the view point was as expected. After adding and removing the Cone, the view point never went back...the bounding box was now wrong.

Dan, I have 11.3 and 12 installed side by side. And in 11.3 I can not reproduce what you report about the bounding box not contracting when the Cone is commented out. Using your original code example.

  • No Cone: View centered at graphics origin
  • Add Cone: View center shifts to right and above the graphics origin
  • Remove Cone: View center returns to the graphics origin
POSTED BY: Hans Milton
Posted 6 years ago

Both ViewCenter and ViewPoint relates to a coordinate system that has its origin in the center of the bounding box, not the graphics coordinate system origin.

One, rather rough, way to get around it is to add invisible points. To force the bounding box to be centered around the graphics origin (or wherever you want the box center to be).

Graphics3D[
    {
     RGBColor[1, 1, 0, 0.8], InfinitePlane[{{0, 0, 0}, {1, 0, 0}, {0, 1, 0}}],
     RGBColor[0.8, 0.8, 0.8, 0.8], Cone[{{1, 1, 0}, {0, 0, 0}}, Sqrt[2]],
     Thickness[0.025], Red, InfiniteLine[{0, 0, 0}, {1, 0, 0}],
     Green, InfiniteLine[{0, 0, 0}, {0, 1, 0}],
     Blue, InfiniteLine[{0, 0, 0}, {0, 0, 1}],
     PointSize[Large], Black, Point[{0, 0, 0}],
     Opacity[0], Point[Tuples[{-2, 2}, {3}]]
    },
    Axes -> True,
    AxesLabel -> {Style["x", Bold, Black], Style["y", Bold, Black], Style["z", Bold, Black]},
    AxesOrigin -> {0, 0, 0},
    AxesEdge -> {{0, 0}, {0, 0}, {0, 0}}, Boxed -> False,
    ViewProjection -> "Orthographic",
    ViewCenter -> {0, 0, 0},
    ViewPoint -> {-0.25, 0.25, 2},
    ViewVertical -> {0, 1, 0}
 ]

By the way, there is no need to wrap a single Graphics3D in Show

POSTED BY: Hans Milton
Posted 6 years ago

EDIT: I noticed that my original view which should be from slightly above and left is now not what I thought it was. View should be from {-0.25,0.25,2} pointed directly at {0,0,0}. For a while the "plane only" demo was viewing this correctly. Now this is viewing from above and right (not left, which it should).

Even with AxesOrigin I'm still running into some related issues. At this point I'm trying to get that AxesOrigin to be viewed from a particular angle regardless of the graphics present. I'll illustrate, where this draws the axis as I want it to be, and emphasizes the X/Y/Z via thick Red/Green/Blue lines on the axes. The other content is a plane with XY orientation. Then I'll add a cone to this by uncommenting the Cone in the code listed below, and you'll see the orientation change despite specifying both ViewPoint and ViewCenter. The first image is from leaving the Cone commented out, the second image is after uncommenting. The view changes when it should not.

The code, with Cone commented out which does what I expect:

Show[
 Graphics3D[
   {
    RGBColor[1, 1, 0, 0.8],
    InfinitePlane [  {  {0, 0, 0}, {1, 0, 0}, {0, 1, 0}  } ],
    (*RGBColor[0.8,0.8,0.8,0.8],
   Cone[ {{1,1,0},{0,0,0}},Sqrt[
   2] ],*)
    {Thickness[0.025], Red, 
    InfiniteLine[{0, 0, 0}, {1, 0, 0}]},
    {Thickness[0.025], Green, InfiniteLine[{0, 0, 0}, {0, 1, 0}]},
    {Thickness[0.025], Blue, InfiniteLine[{0, 0, 0}, {0, 0, 1}]},
    {PointSize[Large], Black, Point[{0, 0, 0}]}
   },
  Axes -> True,
  AxesLabel -> {
    Style["x", Bold, Black],
    Style["y", Bold, Black],
    Style["z", Bold, Black]
    },
  AxesOrigin -> {0, 0, 0},
  AxesEdge -> {{0, 0}, {0, 0}, {0, 0}},
  Boxed -> False,
  ViewProjection -> "Orthographic",
  ViewCenter -> {0, 0, 0},
  ViewPoint -> {-0.25, 0.25, 2},
  ViewVertical -> {0, 1, 0}
  ]
 ]

What this produces when Cone is not shown:

enter image description here


After uncommenting the Cone, the view point changes and should not:

enter image description here

Notice that ViewCenter is told to look directly at {0,0,0}, and ViewPoint should always be from slightly above and left with positive Z going into the screen/paper. Instead, the ViewPoint is altered and forced away from explicitly set coordinates. My earlier failures seem to be partly related to this. Setting AxesOrigin was failing in some cases, and apparently this may be why (the view was changing in ways the AxesOrigin couldn't accomodate). For this case AxesOrigin is now closer to doing as expected, but the view changes.

View used to contain an approximate volume bounded by a bit more than one unit left/right/up/down/in/out from {0,0,0}, but adding the cone changed the viewing volume and shifted everything. Can I force view to about 1.1 units left/right/up/down/in/out from center so that my ViewPoint won't be forced somewhere other than where I specified? I think if I can force the viewed volume to stay constant, then I can add or remove components without everything shifting around.

POSTED BY: Dan Stimits

Try the option:

AxesOrigin -> {0, 0, 0}
POSTED BY: Henrik Schachner
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard