# Rotate the coordinate system to align an existing plane with Y'Z' plane

28 views (last 30 days)

Show older comments

I have a plane z = (-47.407313)*x + (0.322175)*y + (-3.333979) and data points of a ball flight trajectory on it. Even though the best fit is known to be a parabola, since the plane in discussion doesn't align with any of the XY, YZ and ZX planes, it is infeasible to define an explicit relationship z = F(x,y) for obtaining such a curve using curve fitting. Now, my only idea is to rotate the coordinate system so that the plane is parallel to Y'Z' where I can apply (z')=a(y')^2+b(y')+c. After finding the best fit and sampling the points on the fit, I need to retract the coordinate system to get the actual coordinates. Even though the idea seems clear, the application in MATLAB doesn't and I'm hoping someone can guide me with the rotation.

I would be grateful if anyone can suggest an alternate, easier approach to get the 3D best fit equation without this hassle.

##### 3 Comments

### Answers (3)

Bruno Luong
on 16 May 2022

##### 2 Comments

Bruno Luong
on 16 May 2022

Matt J
on 16 May 2022

Edited: Matt J
on 16 May 2022

If you didn't obtain your plane fit with planarFit() from,

then I suggest you do so. If you did use planarFit(), then the rotation is easy:

pfit=planarFit(xyz);

yz_prime = pfit.R(:,2:3)'*xyz;

However, once you've rotated the data this way, you still can't be sure in which direction gravity pulls (see also my comment above).

One solution would be to post-optimize the in-plane rotation of yz

theta=fminbnd(@(theta) postfun(theta,yz_prime), 0,pi);

[~,abc]=postfun(theta,yz_prime)

using the 1D objective function,

function [fval,abc]=postfun(theta,yz_prime)

R=makehgtform('zrotate',theta);

yz=R(1:2,1:2)*yz_prime;

[abc,S]=polyfit(yz(:,1),yz(:,2),2)

fval=S.normr;

end

### See Also

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!