# Plotting three dimensional vectors

6 messages
Open this post in threaded view
|

## Plotting three dimensional vectors

 Good afternoon, I am trying to visualize two simple vectors in three dimensions, and not having much luck. So I thought I would try to create a picture to help. I'm not having much luck there either. I would like to create a plot of the two vectors x=(2, 4, 9) and y=(1, 3, 5), and to display them both on the same graphic with the axis' displayed as well. I have searched through the manual, the help system, and the demos to no avail. There is a lot of information there, but with no starting point, I am just getting further confused. If I'm not asking too much, it would be nice to display each vector in a different color, and to define the axis dimensions (in other words set the x-axis to -5 to 10, the y-axis to 0 to 10, and the z-axis to -10 to 10) Thanks for any help, Jerry
Open this post in threaded view
|

## Re: Plotting three dimensional vectors

 Hi, This can be done, but not directly. You have to plot the (x,y)   component first using xarrows, get the handle of the segs entity then   add a third column to the data field : xarrows(nx,ny) h=gce(); h.data=[h.data nz(:)]; nx, ny, nz are 2 x n matrices containing the origin of vectors on the first line and the extremity on the second line. S. Jerry Nelson <[hidden email]> a écrit : > Good afternoon, > > I am trying to visualize two simple vectors in three dimensions, and   > not having much luck. So I thought I would try to create a picture   > to help. I'm not having much luck there either. > > I would like to create a plot of the two vectors x=(2, 4, 9) and   > y=(1, 3, 5), and to display them both on the same graphic with the   > axis' displayed as well. I have searched through the manual, the   > help system, and the demos to no avail. There is a lot of   > information there, but with no starting point, I am just getting   > further confused. > > If I'm not asking too much, it would be nice to display each vector   > in a different color, and to define the axis dimensions (in other   > words set the x-axis to -5 to 10, the y-axis to 0 to 10, and the   > z-axis to -10 to 10) > > Thanks for any help, > Jerry >
Open this post in threaded view
|

## Re: Plotting three dimensional vectors

 Hi Stepane, Thanks for the response. It was quite timely as I was just getting ready to reply back to my post. I've still been playing around, and I have a bit of a solution. Since I'm dealing with vectors that originate at the origin, I've come up with a macro that will plot the vector as a simple line. That definition is:          function []=myplot3d(a, b, c)          plot3d([0;a],[0;b],[0;c], flag=[5 2 4]);          g=gca();          g.grid=[1 1 1]          g.rotation_angles=[10 25];          g.labels_font_color=5;          g.parent.background=4;          g.background=color(210,210,210);          g.parent.figure_size= [800,600];          g.box="on";          g.labels_font_size=4;          g.x_label.text="x-axis";          g.y_label.text="y-axis";          g.z_label.text="z-axis";          endfunction This allows me to visualize things much better. I am still trying to figure out how to have the three axis's show up, and I wouldn't mind being able to have the line in a color other than black so I can have two distinguishable vectors on the same graphic. Your solution looks like it might do what I'm trying to do, so I will definitely look into it too. Either way I will report back with any successes. Thanks again, Jerry Stephane Mottelet wrote: > Hi, > > This can be done, but not directly. You have to plot the (x,y) component > first using xarrows, get the handle of the segs entity then add a third > column to the > data field : > > xarrows(nx,ny) > h=gce(); > h.data=[h.data nz(:)]; > > nx, ny, nz are 2 x n matrices containing the origin of vectors on the > first line and the extremity on the second line. > > S. > > > > Jerry Nelson <[hidden email]> a écrit : > >> Good afternoon, >> >> I am trying to visualize two simple vectors in three dimensions, and >> not having much luck. So I thought I would try to create a picture to >> help. I'm not having much luck there either. >> >> I would like to create a plot of the two vectors x=(2, 4, 9) and y=(1, >> 3, 5), and to display them both on the same graphic with the axis' >> displayed as well. I have searched through the manual, the help >> system, and the demos to no avail. There is a lot of information >> there, but with no starting point, I am just getting further confused. >> >> If I'm not asking too much, it would be nice to display each vector in >> a different color, and to define the axis dimensions (in other words >> set the x-axis to -5 to 10, the y-axis to 0 to 10, and the z-axis to >> -10 to 10) >> >> Thanks for any help, >> Jerry >> >
Open this post in threaded view
|

## RE: Plotting three dimensional vectors

 In reply to this post by Jerry Nelson Jerry, Please try my attachment. It may help. Regards, cels -----Original Message----- From: Jerry Nelson [mailto:[hidden email]] Sent: Sunday, June 07, 2009 3:24 AM To: [hidden email] Subject: [scilab-Users] Plotting three dimensional vectors Good afternoon, I am trying to visualize two simple vectors in three dimensions, and not having much luck. So I thought I would try to create a picture to help. I'm not having much luck there either. I would like to create a plot of the two vectors x=(2, 4, 9) and y=(1, 3, 5), and to display them both on the same graphic with the axis' displayed as well. I have searched through the manual, the help system, and the demos to no avail. There is a lot of information there, but with no starting point, I am just getting further confused. If I'm not asking too much, it would be nice to display each vector in a different color, and to define the axis dimensions (in other words set the x-axis to -5 to 10, the y-axis to 0 to 10, and the z-axis to -10 to 10) Thanks for any help, Jerry vector.sce (1K) Download Attachment