7
$\begingroup$

For example:

enter image description here

How can I draw such kinds of coordinates?

Thank you~

$\endgroup$
6
  • $\begingroup$ Properly combining Translate[] and Rotate[] ought to do the trick... $\endgroup$ Feb 2, 2012 at 16:08
  • $\begingroup$ This question mathematica.stackexchange.com/questions/1003/… makes me feel you won't get too lucky $\endgroup$
    – Rojo
    Feb 2, 2012 at 16:14
  • $\begingroup$ @J.M. anything to add to that, such as example code? $\endgroup$
    – rcollyer
    Feb 2, 2012 at 16:15
  • $\begingroup$ As Heike says, the 3D axes and ticks aren't fixed and depend on the angle that you've rotated your graphics. With two sets of axes MMA wouldn't even know what to do when you try to rotate your graphics. However, if you don't want anything more from an axes than the set of 3 lines you drew, it's quite simple to do $\endgroup$
    – Rojo
    Feb 2, 2012 at 16:17
  • $\begingroup$ If sam's expecting ticks on his coordinate systems, then I don't think he has a sporting chance. If sam can give the precise conversion formula between his two coordinate systems, I'm sure we can easily produce that diagram... $\endgroup$ Feb 2, 2012 at 16:24

2 Answers 2

12
$\begingroup$

You build this in Mathematica like you would do in any other descriptive language (you might want to use TikZ for this): step by step. Choosing nicer colors,adjusting the distances etc. is left as an exercise to the reader.

cosy[labels_, labelstyle_] := Flatten@{
    Arrow[{{0, 0, 0}, {1, 0, 0}}],
    Arrow[{{0, 0, 0}, {0, 1, 0}}],
    Arrow[{{0, 0, 0}, {0, 0, 1}}],
    labelstyle,
    Text[labels[[1]], {1.1, 0, 0}],
    Text[labels[[2]], {0, 1.1, 0}],
    Text[labels[[3]], {0, 0, 1.1}]
};
Graphics3D[{
    { (* Coordinate system 1 *)

   cosy[{"X", "Y", "Z"}, Darker@Orange],
        Darker@Orange,
        Text["World", {-.3, -.3, .5}]
    },
    { (* Coordinate system 2 *)

   Rotate[cosy[{"x", "y", "z"}, Blue], -30 \[Degree], {-1, 0, 1}]~
    Translate~{0, 0, -2}
    },

    { (* Connecting arrow *)
        Darker@Green,
        Arrow[{{0, 0, 0}, {0, 0, -2}}],
        Text["C(t)", {0, -.2, -1}]
    },

    { (* Red stuff *)
        Red,
        Arrow[{{0, 0, 0}, {0, 3, -1}}],
        Arrow[{{0, 0, -2}, {0, 3, -1}}],
        Text["\!\(\*SubscriptBox[\(p\), \(world\)]\)", 
    1/2 {0, 3, -1} + {0, 0, .5}],
        Text["\!\(\*SubscriptBox[\(p\), \(0\)]\)", 
    1/2 {0, 3, -1} + {0, 0, -1.5}],
        Text["p(t)", {0, 3, -1} + {0, .5, 0}]
    }
  }, Boxed -> False]

enter image description here

$\endgroup$
2
  • 5
    $\begingroup$ Why the Flatten in Graphics3D? It actually makes it more complicated as the inner lists act as scoping constructs: directives within them do not affect the directives outside of them. So, you can remove both Flatten and the second Black and get the same result as cosy ensures that the color directive passed in does not affect anything after it. $\endgroup$
    – rcollyer
    Feb 2, 2012 at 16:58
  • $\begingroup$ Oh, I didn't even know you could use scoping in graphics objects, thank you! Code modified. $\endgroup$
    – David
    Feb 2, 2012 at 17:09
4
$\begingroup$

This is a variation on David's answer.

o = {0, 0, 0};

Clear[axis];
axis[p_, label_] := {Arrowheads[0.025], Arrow[{o, p}], Text[label, p]}

Clear[axes];
axes[labels_List, labelSize_, labelColor_] := 
 MapThread[axis, {IdentityMatrix[3], Style[#, labelSize, labelColor, Bold] & /@ labels}]

ct = 1. {0, 3, 3};
pt = {-0.5, -4, 2};

Graphics3D[{
 axes[{"\!\(\*StyleBox[\"Z\",\nFontSlant->\"Italic\"]\)", "\!\(\*StyleBox[\"X\",\nFontSlant->\"Italic\"]\)", "\!\(\*StyleBox[\"Y\",\nFontSlant->\"Italic\"]\)"}, 17, Blend[{Orange, Yellow}]], 
 Translate[Rotate[axes[{"\!\(\*StyleBox[\"z\",\nFontSlant->\"Italic\"]\)", "\!\(\*StyleBox[\"x\",\nFontSlant->\"Italic\"]\)", "\!\(\*StyleBox[\"y\",\nFontSlant->\"Italic\"]\)"}, 17, Darker@Blue], -35 Degree, {1, 1, 0}], ct], 
 Arrowheads[0.015], Darker@Green, Arrow[{{0, 0, 0}, ct}], 
 Text[Style["C(\!\(\*StyleBox[\"t\",\nFontSlant->\"Italic\"]\))", 14, Bold], Mean[{o, ct}], {-1, 1}], 
 Red, Arrow[{ct, pt}], Text[Style["\!\(\*SubscriptBox[\(p\), \(O\)]\)", 14, Bold], Mean[{ct, pt}], {-.5, -2}], 
 Arrow[{o, pt}], 
 Text[Style["\!\(\*SubscriptBox[StyleBox[\"p\",\nFontSlant->\"Italic\"], \(World\)]\)", 14, Bold], Mean[{o, pt}], {1, 0}], 
 Text[Style["\!\(\*StyleBox[\"p\",\nFontSlant->\"Italic\"]\)(\!\(\*StyleBox[\"t\",\nFontSlant->\"Italic\"]\))", 14, Bold], pt, {-.5, -1}], 
 Text[Style["\!\(\*StyleBox[\"O\",\nFontSlant->\"Italic\"]\)", 20, Bold, Darker@Blue], ct + .1 (pt - ct), {0, -5}]}, 
Boxed -> False, 
ViewVertical -> {0.37, 0.1, 2.1}, 
ViewPoint -> {1.7, 2.5, 1.6}]

two-axes example

The StyleBoxes appeared only because I formatted the fonts with italic and subscripts. The code looks cleaner in my notebook!

To choose values for the ViewVertical and ViewPoint options, I evaluated the expressions, then rotated the graphic to what I thought looked good, then evaluated FullOptions[] on the graphic, using values close what that output gave. Further refinement would involve tuning the angles and positions of the axes labels.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.