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

조회 수: 46 (최근 30일)
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
PASUNURU SAI VINEETH
PASUNURU SAI VINEETH 2022년 5월 16일
편집: PASUNURU SAI VINEETH 2022년 5월 16일
One of the answers helped me. After obtaining the curve fit and sampling, I transformed them back to the original coordinate system where I could apply equations of motion.
Btw, do you know of a way I can directly fit a 3D curve (not the surface or a spline along the surface that isn't smooth)? The process is straightforward for 2D and I couldn't do the 3D fit even after projecting all the points to the best fit plane (angled to the XY, YZ and ZX). I am looking to eliminate this hassle of plane projection and double transformation.
Matt J
Matt J 2022년 5월 16일
You would need a parametric model for the 3D trajectory (x(t), y(t),z(t))

댓글을 달려면 로그인하십시오.

답변 (3개)

Torsten
Torsten 2022년 5월 15일
편집: Torsten 2022년 5월 15일
But are you sure that the parabola in the YZ plane is not also rotated ?
  댓글 수: 5
PASUNURU SAI VINEETH
PASUNURU SAI VINEETH 2022년 5월 16일
Okay, I understand your point now. Yeah the parabola need not be aligned with the Z-axis. It somehow worked for this case but do you suggest a general formula ay^2+bz^2+cyz+dy+ez+f=0 when the direction of directrix is arbritary?
Torsten
Torsten 2022년 5월 16일
If you have a 3d-model of the parabola of the form
(a*t^2+b*t+c;d*t^2+e*t+f;g*t^2+h*t+i)
you can directly fit the 9 parameters in question.

댓글을 달려면 로그인하십시오.


Bruno Luong
Bruno Luong 2022년 5월 16일
Take a look at this thread and see if you can use it
  댓글 수: 2
PASUNURU SAI VINEETH
PASUNURU SAI VINEETH 2022년 5월 16일
Appreciate your response. The thread Torsten shared helped me.
Btw, do you know of a way I can directly fit a 3D curve (not the surface or a spline along the surface that isn't smooth)? The process is straightforward for 2D and I couldn't do the 3D fit even after projecting all the points to the best fit plane (angled to the XY, YZ and ZX). I am looking to eliminate this hassle of plane projection and double transformation.
Bruno Luong
Bruno Luong 2022년 5월 16일
The answer I gave in the above thread shows to use SVD to fit a point clouds, the input point cloud can be a non degenerated curve (i.e. not a line) and not necessary a plane.

댓글을 달려면 로그인하십시오.


Matt J
Matt J 2022년 5월 16일
편집: Matt J 2022년 5월 16일
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
  댓글 수: 1
PASUNURU SAI VINEETH
PASUNURU SAI VINEETH 2022년 5월 17일
Thank you. I have used Least Squares method for finding the coefficients of best fit plane. I will definitely try the method you've suggested.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Get Started with Curve Fitting Toolbox에 대해 자세히 알아보기

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by