Azzera filtri
Azzera filtri

How to change the coordinate system of a 3D graph?

6 visualizzazioni (ultimi 30 giorni)
Sagar Chawla
Sagar Chawla il 31 Mar 2022
Risposto: Rahul il 4 Set 2024
% prepare environment and generate aircraft trajectory clear all; close all; clc; data = zeros(400,6);
% x, y and z coordinates data(:,1) = 0; data(:,2) = .5:.5:200; data(:,3) = 500;
% pitch, yaw and roll angle values data(:,4) = 0; data(:,5) = 0; data(21:380,6) = (1:1:360)/57.3;
% prepare aircraft simulation model new_object('aircraft.mat',data,... 'model','f-16.mat', 'edge',[.1 .1 .1],'face',[.1 .1 .1],... 'path','on','pathcolor', [.89 .0 .27],'pathwidth',1,'scale',1);
% generate the scene and save the result as gif file flypath('aircraft.mat',... 'animate','on','step',3,... 'font','Georgia','fontsize',10,... 'view',[35 45],'window',[700 700],... 'output','aileron_roll.gif',... 'xlim',[-20 20],'ylim',[0 200], 'zlim',[480 520]); The image shows the diagram on a z, x & y axis. I want to change coordinates as z in place of x and y in place of z and x in place of y.
  1 Commento
Ashok
Ashok il 30 Ago 2024
Modificato: Ashok il 30 Ago 2024
Hey Sagar,
You can refer to your other question, titled "Coordinate system or axis system", through the below link for the answer.

Accedi per commentare.

Risposte (1)

Rahul
Rahul il 4 Set 2024
I understand that you want to change the axis of your 'data' as z in place of x and y in place of z and x in place of y before adding to the 'new_object_model' which is futher used in the 'flypath' function.
You can change the coordinate axis by creating a tranformed_data array as mentioned below:
% Transform coordinates: swap x -> y, y -> z, z -> x
transformed_data = zeros(size(data));
transformed_data(:,1) = data(:,3);
transformed_data(:,2) = data(:,1);
transformed_data(:,3) = data(:,2);
This 'transformed_data' array can be passed in place of 'data' to custom functions like 'new_object' and 'flypath' mentioned in your code to change the axis of simulation as mentioned by you.
You can refer to the following documentations to know more about MATLAB functions and Simulink blocks for achieving the desired result:
Hope this helps! Thanks.

Categorie

Scopri di più su Guidance, Navigation, and Control (GNC) in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by