How to plot vectors as 3D plot

1 次查看(过去 30 天)
Maitha bin gharib
评论: KSSV 2016-4-5
So i have a platform and a base. The platform has the following points B1= (15 15 0) B2= (-15 15 0) B3= (-15 -15 0) B4= (15 -15 0) And it's moving so i put those points in an equation with respect to some angles so it becomes b1 = P + (R*B1) b2 = P + (R*B2) b3 = P + (R*B3) b4 = P + (R*B4) Where P is [0 0 20] and R is a rotation matrix with respect to some angles And the base has the corresponding points A1 = (5 14 0) A2= (-30 30 0) A3= (-30 -30 0) A4= (5 -14 0)
How do i plot bi and Ai such that the base is connected with the platform with a line between the point in the platform with the corresponding one in the base ?

回答(1 个)

KSSV
KSSV 2016-4-5
Are you expecting something like this?
clc; clear all ;
% Platform
B = [15 15 0 ;
-15 15 0 ;
-15 -15 0 ;
15 -15 0] ;
P = [0 0 20] ;
P = repmat(P,[4,1]) ;
% A random rotation
R = rand(1,3) ;
R = repmat(R,[4,1]) ;
%
b1 = P + (R.*B) ;
% Base
A = [5 14 0 ;
-30 30 0 ;
-30 -30 0 ;
5 -14 0] ;
my_vertices = [A ; b1] ;
my_faces = [1 2 3 4; 2 6 7 3; 4 3 7 8; 1 5 8 4; 1 2 6 5; 5 6 7 8];
patch('Vertices', my_vertices, 'Faces', my_faces, 'FaceColor', 'w');
  2 个评论
Maitha bin gharib
What does repmat mean? R is not a random variable, it's a 3x3 matrix with a specific formula that I haven't mentioned here
KSSV
KSSV 2016-4-5
Yeah..I thought so...It can be modified...for R as 3x3

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Surface and Mesh Plots 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by