How to plot vectors as 3D plot

4 ビュー (過去 30 日間)
Maitha bin gharib
Maitha bin gharib 2016 年 4 月 5 日
コメント済み: 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
Maitha bin gharib 2016 年 4 月 5 日
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 Center および File ExchangeSurface and Mesh Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by