# Can Someone explain Dir, and Up in relation to camera settings?

I am in the debug menu for cameras in Sketchup and I understand the “Eye” values but can’t wrap my head around “Dir” and “Up.”

Also, how would I go about converting XYZ rotation values to these values?

Dir is the vector along which the axis of the camera is pointing. Up is the vector that defines the y axis of the camera plane, which usually is toward the top of the view window.

1 Like

hmmm… so if I wanted rotate my camera with XYZ rotation (for example X:120d, Y:0d, Z:-90d) how would I go about this?

I’m not where I can try it, but I think you would need to transform the vectors, create a new camera using them, and assign it to the view.

That Camera panel is strictly a Windows thing, is it not? You use a ruby command to get it?

There is advanced camera tools, which allows you various setting and even manual manipulation of geometry cameras.

I have advanced camera tools, but always struggled with it.

I’m no expert with it either, but I do know you can physically move the camera around and the scenes will respect that.

I don’t know if this is something you would know but I found this. Know if this works?

def xyz_to_dir_up(x, y, z)

# Convert the XYZ rotation values to radians.

x_rad = x * Math::PI / 180
y_rad = y * Math::PI / 180
z_rad = z * Math::PI / 180

# Create a transformation matrix to rotate the camera.

transform = Geom::Transformation.rotation(ORIGIN, Z_AXIS, z_rad) *

# Apply the transformation to the “Dir” and “Up” vectors.

dir = transform * Z_AXIS
up = transform * Y_AXIS

# Return the transformed “Dir” and “Up” vectors.

[dir, up]
end

The values shown are normalized vectors. The DIR vector is the direction the camera is aiming. If you have a line pointing to where you want the camera to point, construct a box around the line using it as a diagonal and then calculate the X, Y, and Z vector components.

If you want the camera upright, just specify 0,0,1 as the values for UP (i.e., Z_AXIS).

[NOTE: The SQRT(X^2 + Y^2 + Z^2) is the length of the diagonal]

If you make your line 1 unit long, you can read the other values directly: