2
$\begingroup$

This question is a continuation of the previous one:

How to draw a cube?

Draw a cube, ABCD-A1B1C1D1, with the length of the edge as 1. How to draw this cube and establish a space rectangular coordinate system at the same time. Point A on the bottom is the origin of the coordinate system, the line AB is on the x-axis, the line AD is on the y-axis, and the line AA1 is on the z-axis.

After establishing the spatial rectangular coordinate system, the coordinates of each vertex of the cube are known.How can I get the coordinates of a vector composed of any two vertices? Can I get it automatically?

For example, if you input vector AB, you can get the coordinate AB of vector AB={1,0,0}and so on...

$\endgroup$

1 Answer 1

5
$\begingroup$
reg = Parallelepiped[{0, 0, 0}, {{1, 0, 0}, {0, 1, 0}, {0, 0, 1}}];
pts = MeshPrimitives[reg, 0];
g = HighlightMesh[
  reg, {Labeled[0, "Index"], Style[2, Directive[White, Opacity[.1]]]}]

enter image description here

  • For two points,for example 6 and 4.
v[6, 4] = pts[[;; , 1]][[6]] - pts[[;; , 1]][[4]]
With[{i = 6, j = 4}, 
 Graphics3D[{{White, Lighting -> {{"Ambient", White}}, g}, Red, 
   Arrow[{pts[[;; , 1]][[i]], pts[[;; , 1]][[j]]}]}, Boxed -> False]]

enter image description here

  • Labeled
HighlightMesh[reg, {Labeled[{0, 1}, Style["A", Red, 15]], 
  Labeled[{0, 2}, Style["B", 15]], Labeled[{0, 4}, Style["D", 15]], 
  Labeled[{0, 5}, Style["A1", 15]], Labeled[{0, 6}, Style["E", 15]], 
  Style[2, Directive[White, Opacity[.1]]]}]

enter image description here

  • We can also use Graphics3D+Text to draw such picture, but here we let it be a exercise.
$\endgroup$
1
  • $\begingroup$ Can't we mark the corresponding letters on the vertices? $\endgroup$
    – csn899
    Jan 30, 2023 at 1:59

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.