Contact
CoCalc Logo Icon
StoreFeaturesDocsShareSupport News AboutSign UpSign In
| Download
Views: 235
%hide %html <H3><FONT COLOR="#030856">Plots lines and planes in 3D surfaces</FONT></H3> <FONT COLOR="#830806"> <U>Source</U>: Many of the ideas and strategies in this worksheet are taken from the excellent resource on doing multivariate calculus in Sage by Prof. </FONT> <P></P> In this module we will learn how to plot lines, planes and surfaces in 3D. The three basic sage functions we will use most frequently for 3D plotting are: <P></P> <UL> <LI><TT>plot3d()</TT></LI> <LI><TT>implicit_plot3d()</TT></LI> <LI><TT>parametric_plot()</TT></LI> </UL> <P></P> Run the builtin help on each of these functions to see the extensive range of features and options they offer: <P></P> <UL> <TT>plot3d?</TT> <BR> <TT>implicit_plot3d?</TT><BR> <TT>parametric_plot?</TT> </UL> <P>&nbsp;</P> <B> This module assumes you know how to define and work with vectors. <P></P> If not, please review/complete that module first. </B>

Plots of 3D surfaces

Source: Many of the ideas and strategies in this worksheet are taken from the excellent resource on doing multivariate calculus in Sage by Prof.

In this module we will learn how to plot lines, planes and surfaces in 3D. The three basic sage functions we will use most frequently for 3D plotting are:

  • plot3d()
  • implicit_plot3d()
  • parametric_plot()

Run the builtin help on each of these functions to see the extensive range of features and options they offer:

    plot3d?
    implicit_plot3d?
    parametric_plot?

 

This module assumes you know how to define and work with vectors.

If not, please review/complete that module first.
Example 1: Find and plot each of the following as instructed:

  1. The line passing through the point (2,0,1)(2,0,1) and parallel to the vector i+jk{\bf i} + {\bf j} - {\bf k}.
    Show the line and the parallel vector in your plot.
  2. The line passing through the points (2,0,1)(2,0,1) and (0,2,0)(0,2,0)
  3. The plane passing through the point (2,0,1)(2,0,1) and perpendicular to the vector ijk-{\bf i} - {\bf j} - {\bf k}
  4. . Show the vector and the plane in your plot.
  5. The line of intersection of the planes 3x+2y+z=33x+2y+z=3 and x2y+3z=1x-2y+3z=1
  6. . Show the planes and the line of intersection in your plot.

# Example 1a: The line passing through the point (2,0,1) and # parallel to the vector i+j-k: t = var('t') r0 = vector( [2,0,1] ) # position vector of given point v = vector( [1,1,-1] ) # the parallel vector r = r0 + t*v # the answer, i.e., line through r0 and parallel to v print r myline = parametric_plot(r, (t,-4,4), color='green', thickness=3) myvec = plot(v, thickness=3) show(myline + myvec)
(t + 2, t, -t + 1)
3D rendering not yet implemented
# Example 1b: The line passing through the points (2,0,1) and # (0,2,0): t = var('t') r0 = vector( [2,0,1] ) # position vector of 1st point r2 = vector( [0,2,0] ) # position vector of 2nd point v = r2-r0 # vector from point 1 to point 2 r = r0 + t*v # the answer, i.e., line through r0 and parallel to v print r myline = parametric_plot(r, (t,-4,4), color='green', thickness=3) myvec = plot(v, thickness=3) show(myline + myvec)
(-2*t + 2, 2*t, -t + 1)
3D rendering not yet implemented
# Example 1c: The plane passing through the point (2,0,1) and # perpendicular to the vector -i-j-k: x, y, z = var('x, y, z') myv = vector( [x, y, z] ) # Define a vector with variable components. r0 = vector( [2,0,1] ) # Position vector of given point. np = vector( [-1,-1,-1] ) # Given normal vector. myplane = np.dot_product(myv-r0) # This uses the fact that we can dot the # normal vector with <x-v1,y-v2,z-v3> to # get the LHS of the plane. print 'The plane is:', myplane, '= 0' print ' ' p = implicit_plot3d(myplane == 0, (x,-5,5), (y,-5,5), (z,-5,5), color='green' ) q = plot(np, thickness=3) show(p+q)
The plane is: -x - y - z + 3 = 0
3D rendering not yet implemented