TensorTonicTensorTonic
Problems
Study PlansProjectsNewInterviewPricingFeedback
Problems
Loading...
1 / 1

Rotate 3D Point Around Z-Axis

3D Geometry
Medium

Rotate one 3D point or a batch of points around the z-axis by angle θ\thetaθ radians. Compute each transformed coordinate separately:

x′=xcos⁡θ−ysin⁡θx'=x\cos\theta-y\sin\thetax′=xcosθ−ysinθ y′=xsin⁡θ+ycos⁡θy'=x\sin\theta+y\cos\thetay′=xsinθ+ycosθ z′=zz'=zz′=z

Here, (x,y,z)(x,y,z)(x,y,z) is an input point. Preserve the input shape and return a floating-point NumPy array.

Loading visualization...

Examples

Input: points = [1, 0, 0], theta = 1.5707963267948966

Output: [0, 1, 0]

Explanation: A positive quarter-turn maps the positive x-axis onto the positive y-axis.

Input: points = [[1, 0, 0], [0, 1, 2]], theta = 1.5707963267948966

Output: [[0, 1, 0], [-1, 0, 2]]

Hint 1

Read coordinates with values[..., 0], values[..., 1], and values[..., 2].

Hint 2

Stack the transformed coordinates with np.stack(..., axis=-1).

Requirements

  • Apply the rotation to every point without looping over batch rows
  • Leave each z-coordinate unchanged
  • Accept shape (3,) or (N, 3)
  • Return a NumPy array with the input shape

Constraints

  • theta is measured in radians
  • Use NumPy only
Try Similar Problems
Homogeneous TransformAngle Between 3dNormalize 3dImage Rotation NearestVector Norm 3d

Sign in to take notes on this problem

Case 1
Case 2

Accepts: array

Accepts: number

You must run your code first.
PrevNext

Rotate 3D Point Around Z-Axis

3D Geometry
Medium

Rotate one 3D point or a batch of points around the z-axis by angle θ\thetaθ radians. Compute each transformed coordinate separately:

x′=xcos⁡θ−ysin⁡θx'=x\cos\theta-y\sin\thetax′=xcosθ−ysinθ y′=xsin⁡θ+ycos⁡θy'=x\sin\theta+y\cos\thetay′=xsinθ+ycosθ z′=zz'=zz′=z

Here, (x,y,z)(x,y,z)(x,y,z) is an input point. Preserve the input shape and return a floating-point NumPy array.

Loading visualization...

Examples

Input: points = [1, 0, 0], theta = 1.5707963267948966

Output: [0, 1, 0]

Explanation: A positive quarter-turn maps the positive x-axis onto the positive y-axis.

Input: points = [[1, 0, 0], [0, 1, 2]], theta = 1.5707963267948966

Output: [[0, 1, 0], [-1, 0, 2]]

Hint 1

Read coordinates with values[..., 0], values[..., 1], and values[..., 2].

Hint 2

Stack the transformed coordinates with np.stack(..., axis=-1).

Requirements

  • Apply the rotation to every point without looping over batch rows
  • Leave each z-coordinate unchanged
  • Accept shape (3,) or (N, 3)
  • Return a NumPy array with the input shape

Constraints

  • theta is measured in radians
  • Use NumPy only
Try Similar Problems
Homogeneous TransformAngle Between 3dNormalize 3dImage Rotation NearestVector Norm 3d

Sign in to take notes on this problem

Case 1
Case 2

Accepts: array

Accepts: number

You must run your code first.