How to plot vectors as 3D plot

조회 수: 3 (최근 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 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