model-x

model-y

model-z

screen-x

screen-y

screen-z

model-x

Arguments
[x y z]
Docstring
Returns the three-dimensional x, y, z position in model space. This
returns the x value for a given coordinate based on the current set
of transformations (scale, rotate, translate, etc.) The x value can
be used to place an object in space relative to the location of the
original point once the transformations are no longer in use.
Works only inside sketch functions?
Yes
Original Processing method
modelX()
Example
(let [gr3d (q/create-graphics 240 240 :p3d)
      gr-text (q/create-graphics 240 240 :java2d)]
  (q/with-graphics gr3d
    (q/background 255)
    (q/camera 50 25 13 0 0 0 0 0 -1)
    (q/stroke-weight 2)
    (q/stroke 255 0 0)
    (q/line 0 0 0 20 0 0)
    (q/stroke 0 255 0)
    (q/line 0 0 0 0 20 0)
    (q/stroke 0 0 255)
    (q/line 0 0 0 0 0 20)
    (q/stroke 255 0 0)
    (q/stroke-weight 5)
    (q/translate 10 20 5)
    (q/point 0 0 0)
    (let [x (q/model-x 0 0 0)
          y (q/model-y 0 0 0)
          z (q/model-z 0 0 0)]
      (q/with-graphics gr-text
        (q/background 255)
        (q/fill 0)
        (doseq [[ind capt val] [[1 "(q/model-x 0 0 0)" x]
                                [2 "(q/model-y 0 0 0)" y]
                                [3 "(q/model-z 0 0 0)" z]]]
          (q/text (str capt " is " val) 20 (* ind 20))))))
  (q/image gr3d 0 0)
  (q/image gr-text 250 0))
try example

model-y

Arguments
[x y z]
Docstring
Returns the three-dimensional x, y, z position in model space. This
returns the y value for a given coordinate based on the current set
of transformations (scale, rotate, translate, etc.) The y value can
be used to place an object in space relative to the location of the
original point once the transformations are no longer in use.
Works only inside sketch functions?
Yes
Original Processing method
modelY()
Example
(let [gr3d (q/create-graphics 240 240 :p3d)
      gr-text (q/create-graphics 240 240 :java2d)]
  (q/with-graphics gr3d
    (q/background 255)
    (q/camera 50 25 13 0 0 0 0 0 -1)
    (q/stroke-weight 2)
    (q/stroke 255 0 0)
    (q/line 0 0 0 20 0 0)
    (q/stroke 0 255 0)
    (q/line 0 0 0 0 20 0)
    (q/stroke 0 0 255)
    (q/line 0 0 0 0 0 20)
    (q/stroke 255 0 0)
    (q/stroke-weight 5)
    (q/translate 10 20 5)
    (q/point 0 0 0)
    (let [x (q/model-x 0 0 0)
          y (q/model-y 0 0 0)
          z (q/model-z 0 0 0)]
      (q/with-graphics gr-text
        (q/background 255)
        (q/fill 0)
        (doseq [[ind capt val] [[1 "(q/model-x 0 0 0)" x]
                                [2 "(q/model-y 0 0 0)" y]
                                [3 "(q/model-z 0 0 0)" z]]]
          (q/text (str capt " is " val) 20 (* ind 20))))))
  (q/image gr3d 0 0)
  (q/image gr-text 250 0))
try example

model-z

Arguments
[x y z]
Docstring
Returns the three-dimensional x, y, z position in model space. This
returns the z value for a given coordinate based on the current set
of transformations (scale, rotate, translate, etc.) The z value can
be used to place an object in space relative to the location of the
original point once the transformations are no longer in use.
Works only inside sketch functions?
Yes
Original Processing method
modelZ()
Example
(let [gr3d (q/create-graphics 240 240 :p3d)
      gr-text (q/create-graphics 240 240 :java2d)]
  (q/with-graphics gr3d
    (q/background 255)
    (q/camera 50 25 13 0 0 0 0 0 -1)
    (q/stroke-weight 2)
    (q/stroke 255 0 0)
    (q/line 0 0 0 20 0 0)
    (q/stroke 0 255 0)
    (q/line 0 0 0 0 20 0)
    (q/stroke 0 0 255)
    (q/line 0 0 0 0 0 20)
    (q/stroke 255 0 0)
    (q/stroke-weight 5)
    (q/translate 10 20 5)
    (q/point 0 0 0)
    (let [x (q/model-x 0 0 0)
          y (q/model-y 0 0 0)
          z (q/model-z 0 0 0)]
      (q/with-graphics gr-text
        (q/background 255)
        (q/fill 0)
        (doseq [[ind capt val] [[1 "(q/model-x 0 0 0)" x]
                                [2 "(q/model-y 0 0 0)" y]
                                [3 "(q/model-z 0 0 0)" z]]]
          (q/text (str capt " is " val) 20 (* ind 20))))))
  (q/image gr3d 0 0)
  (q/image gr-text 250 0))
try example

screen-x

Arguments
[x y][x y z]
Docstring
Takes a three-dimensional x, y, z position and returns the x value
for where it will appear on a (two-dimensional) screen, once
affected by translate, scale or any other transformations
Works only inside sketch functions?
Yes
Original Processing method
screenX()
Example
(let [gr3d (q/create-graphics 240 240 :p3d)
      gr-text (q/create-graphics 240 240 :java2d)]
  (q/with-graphics gr3d
    (q/background 255)
    (q/camera 13 25 50 0 0 0 0 0 -1)
    (q/stroke-weight 2)
    (q/stroke 255 0 0)
    (q/line 0 0 0 20 0 0)
    (q/stroke 0 255 0)
    (q/line 0 0 0 0 20 0)
    (q/stroke 0 0 255)
    (q/line 0 0 0 0 0 20)
    (q/stroke 255 0 0)
    (q/stroke-weight 7)
    (q/point 0 0 0)
    (q/point 10 5 7)
    (let [x1 (q/screen-x 0 0)
          x2 (q/screen-x 10 5 7)
          y1 (q/screen-y 0 0)
          y2 (q/screen-y 10 5 7)
          z1 (q/model-z 0 0 0)
          z2 (q/model-z 10 5 7)]
      (q/with-graphics gr-text
        (q/background 255)
        (q/fill 0)
        (doseq [[ind capt val]
                  [[1 "(q/screen-x 0 0)" x1] [2 "(q/screen-x 10 5 6)" x2]
                   [3 "(q/screen-y 0 0)" y1] [4 "(q/screen-y 10 5 6)" y2]
                   [5 "(q/screen-z 0 0 0)" x1] [6 "(q/screen-z 10 5 6)" z2]]]
          (q/text (str capt " is " val) 20 (* ind 20))))))
  (q/image gr3d 0 0)
  (q/image gr-text 250 0))
try example

screen-y

Arguments
[x y][x y z]
Docstring
Takes a three-dimensional x, y, z position and returns the y value
for where it will appear on a (two-dimensional) screen, once
affected by translate, scale or any other transformations
Works only inside sketch functions?
Yes
Original Processing method
screenY()
Example
(let [gr3d (q/create-graphics 240 240 :p3d)
      gr-text (q/create-graphics 240 240 :java2d)]
  (q/with-graphics gr3d
    (q/background 255)
    (q/camera 13 25 50 0 0 0 0 0 -1)
    (q/stroke-weight 2)
    (q/stroke 255 0 0)
    (q/line 0 0 0 20 0 0)
    (q/stroke 0 255 0)
    (q/line 0 0 0 0 20 0)
    (q/stroke 0 0 255)
    (q/line 0 0 0 0 0 20)
    (q/stroke 255 0 0)
    (q/stroke-weight 7)
    (q/point 0 0 0)
    (q/point 10 5 7)
    (let [x1 (q/screen-x 0 0)
          x2 (q/screen-x 10 5 7)
          y1 (q/screen-y 0 0)
          y2 (q/screen-y 10 5 7)
          z1 (q/model-z 0 0 0)
          z2 (q/model-z 10 5 7)]
      (q/with-graphics gr-text
        (q/background 255)
        (q/fill 0)
        (doseq [[ind capt val]
                  [[1 "(q/screen-x 0 0)" x1] [2 "(q/screen-x 10 5 6)" x2]
                   [3 "(q/screen-y 0 0)" y1] [4 "(q/screen-y 10 5 6)" y2]
                   [5 "(q/screen-z 0 0 0)" x1] [6 "(q/screen-z 10 5 6)" z2]]]
          (q/text (str capt " is " val) 20 (* ind 20))))))
  (q/image gr3d 0 0)
  (q/image gr-text 250 0))
try example

screen-z

Arguments
[x y z]
Docstring
Given an x, y, z coordinate, returns its z value.
 This value can be used to determine if an x, y, z coordinate is in
 front or in back of another (x, y, z) coordinate. The units are
 based on how the zbuffer is set up, and don't relate to anything
 'real'. They're only useful for in comparison to another value
 obtained from screen-z, or directly out of the zbuffer
Works only inside sketch functions?
Yes
Original Processing method
screenZ()
Example
(let [gr3d (q/create-graphics 240 240 :p3d)
      gr-text (q/create-graphics 240 240 :java2d)]
  (q/with-graphics gr3d
    (q/background 255)
    (q/camera 13 25 50 0 0 0 0 0 -1)
    (q/stroke-weight 2)
    (q/stroke 255 0 0)
    (q/line 0 0 0 20 0 0)
    (q/stroke 0 255 0)
    (q/line 0 0 0 0 20 0)
    (q/stroke 0 0 255)
    (q/line 0 0 0 0 0 20)
    (q/stroke 255 0 0)
    (q/stroke-weight 7)
    (q/point 0 0 0)
    (q/point 10 5 7)
    (let [x1 (q/screen-x 0 0)
          x2 (q/screen-x 10 5 7)
          y1 (q/screen-y 0 0)
          y2 (q/screen-y 10 5 7)
          z1 (q/model-z 0 0 0)
          z2 (q/model-z 10 5 7)]
      (q/with-graphics gr-text
        (q/background 255)
        (q/fill 0)
        (doseq [[ind capt val]
                  [[1 "(q/screen-x 0 0)" x1] [2 "(q/screen-x 10 5 6)" x2]
                   [3 "(q/screen-y 0 0)" y1] [4 "(q/screen-y 10 5 6)" y2]
                   [5 "(q/screen-z 0 0 0)" x1] [6 "(q/screen-z 10 5 6)" z2]]]
          (q/text (str capt " is " val) 20 (* ind 20))))))
  (q/image gr3d 0 0)
  (q/image gr-text 250 0))
try example