ASKSAGE: Sage Q&A Forum - Latest question feedhttp://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Sat, 06 Apr 2019 17:10:33 -0500Point -> Vector to a pointhttp://ask.sagemath.org/question/46034/point-vector-to-a-point/Hello everyone,
If i have point in 3D
A=point3d((4,3,2),size=10,color='red',opacity=.5)
How to create a vector from the origin to the point.
I know i could define the vector. But I would rather have a point, for plotting reasons
And i would like to plot the Point and the Vector, with automatic labeling of the coordinates.
I have managed to do this like:
from sage.plot.plot3d.shapes2 import frame3d
F=frame3d([0,0,0],vector([10,10,10]),color='red')
A=points((4,3,2),size=10,color='red',opacity=.5)
B=point([(4,3,8)],size=10,color='red',opacity=.5)
t = var('t')
p = vector([4,3,2])
q = vector([0,0,0])
vec=parametric_plot3d(p*t+q, (t,0,1))
#vectB=vector(B.xdata[1],B.ydata[1],B.zdata[1])
e=0.2
eps=vector([4+e,3+e,2+e])
T_A = text3d('A',eps)
#T_B = text3d('B',B)
F+A+T_A+B+vec
Is there any better, way to do it?
Here is the file:
https://share.cocalc.com/share/a3f14e05-7729-406f-97c5-be5b73646381/vector/ebene.sagews?viewer=sharethethaSat, 06 Apr 2019 17:10:33 -0500http://ask.sagemath.org/question/46034/Line,Plane, Points 3D, Intersection,http://ask.sagemath.org/question/46033/lineplane-points-3d-intersection/Is there a tutorial on
-analytical geometry(vectors) :
plane
line
2D circle in 3D,
plot chains of vectors, basicaly the everything what this thing can do: https://www.geogebra.org/3d?lang=de
well allmost everything in vector geometry
for python or sagemath.
Maybe someone saw a book or tutorial on this
I can not find anything on this.
I have managed to plot points
from sage.plot.plot3d.shapes2 import frame3d
F=frame3d([0,0,0],vector([10,10,10]),color='red')
A=point3d((4,3,2),size=10,color='red',opacity=.5)
e=0.2
eps=vector([4+e,3+e,2+e])
T = text3d('A',eps)
F+A+T
I didnt manage to label, point A(4,3,2), to to do it? I would rather not put the coordinates as a string. Is there something like in c++ "The point is %d"
Is there a better way to plot? I need the frame, since the plot 3d is not accepting, text, or maybe i am wrong?
Would there by a natural way to plot x,y,z axes?
Here is the Code
https://share.cocalc.com/share/a3f14e05-7729-406f-97c5-be5b73646381/vector/ebene.sagews?viewer=sharethethaSat, 06 Apr 2019 12:52:46 -0500http://ask.sagemath.org/question/46033/subset of sphere defined by inequalitieshttp://ask.sagemath.org/question/45675/subset-of-sphere-defined-by-inequalities/I need to draw several geodesics on a subset of a unit sphere, namely the set of all points with z-coordinate -0.5<z<0.5
1)How do I define the object?
A = sphere((0,0,0), 1)
How to cut off the domain that i need?
I'm a complete novice and failed to find the answer in the documentation.
2) What's the right way to draw a segment of a big circle between two points on a sphere given in spherical coordinates?DmitriTue, 05 Mar 2019 15:43:54 -0600http://ask.sagemath.org/question/45675/Deformed 3d shapeshttp://ask.sagemath.org/question/44887/deformed-3d-shapes/ Hi
I am a beginner in sagemaths and I would like to print a cube that has been deformed. I have the 3 vectors of the side of the cube but I really don't know how modelise it.
Would you have any idea ?
Thank you very muchZ_etuFri, 04 Jan 2019 04:52:29 -0600http://ask.sagemath.org/question/44887/How to draw figures of Polygons in SageMathhttp://ask.sagemath.org/question/41610/how-to-draw-figures-of-polygons-in-sagemath/ I want to draw a picture of a polygon in SageMath which will be unfilled
i.e I want to draw figures of triangle,square,pentagon,hexagon and so on and then draw a figure with say 100 sides.
I checked the web.
I only found plots of 3d figures ,I want 2d figures .
Is it possible to draw such a figure in SageMath.
Please help meCaptchaSun, 18 Mar 2018 02:14:08 -0500http://ask.sagemath.org/question/41610/How to draw geometrical figures with coordinate axeshttp://ask.sagemath.org/question/41053/how-to-draw-geometrical-figures-with-coordinate-axes/ I would like to draw geometrical figures with coordinate axes. suppose I want to draw a sphere with three coordinate axes x,y,z. How can I do this?MKSFri, 09 Feb 2018 21:08:29 -0600http://ask.sagemath.org/question/41053/How do you find all three angles ?Are there any proof of how to claim all three?http://ask.sagemath.org/question/41011/how-do-you-find-all-three-angles-are-there-any-proof-of-how-to-claim-all-three/
For a triangle of $\angle A B C$ the sides of $ a,b,c$ are written in a way of $a=\frac{\sin A}{\sin C}$, $b=\frac{\sin B}{\sin C}$, $c=\frac{\sin C}{\sin C}$ and the heights $h_a,h_b,h_c$ are written in a form $\frac {h_c}{h_a}=$,$\frac{h_c}{h_b}=$,$\frac{h_c}{h_c}$ to give us $ a$ and $b$. and the base $c=1$.
If I have a triangle with sides $5,5,4 $ and their altitudes are $\sqrt {21},\sqrt {13.44},\sqrt {13.44}$ , why do they simplify to give us a special kind of triangle where $a=1.25,b=1.25,c=1$
>$\sqrt\frac {21}{13.44}=1.25$
Angles
$3=0.16+0.16+0.68^2+0.84+0.84+(1-0.68^2)$
Laws of Cosine ,when we have all $3$ lengths are:
>$a^2=b^2+c^2-2bc\cos(A)$
>$b^2=a^2+c^2-2ac\cos(B)$
>$c^2=a^2+b^2-2ab\cos(C)$
Here we have sides $1.25,1.25 and 1$,a simplest version of the triangle measuring $5,5,4$.
And for three sides of a triangle $a,b,c$,and $\angle ABC$. The legs of the heights $h_a,h_b,h_c$ are situated on three sides of the triangle.
For one side $a$ I have $\frac{b-\cos(A)}{\cos(C)}=a$ and for the second side $b$ I have $\frac{a-\cos(B)}{\cos(C)}=b$ and the third side which is $c$ as the base of the triangle equals to $1$.
>$\sqrt{\sin^2(B)+(a-\cos(B))^2}=b$
>$\sqrt{\sin^2(A)+(b-\cos(A))^2}=a$
>$\sqrt{\sin^2(A)+(\cos(A))^2}=c$
>by using consecutive or non consecutive numbers:
>$a<b<c $ we're able to define $\theta$ without conversion
>$\frac{a}{c}=\cos(C)$ $(1-\frac{a}{c})\times\sqrt\frac{(a+c)}{(c-a)}=\sin(C)$
>$\sqrt\frac{(c-b)}{c}=\cos(B)$ $\sqrt\frac{b}{c}=\sin(B)$
Find
>$\cos(A)$ & $\sin(A)$ which we already know.
> Question is: why $\frac{h_c}{h_b}$; $\frac{h_c}{h_a}$;$\frac{h_c}{h_c}$ and. $\frac{\sin A}{\sin C}$; $\frac{\sin B}{\sin C}$ $\frac{\sin C}{\sin C}$equal to the sides $a,b,c$?LarrousseWed, 07 Feb 2018 08:45:18 -0600http://ask.sagemath.org/question/41011/How can I sketch the graph in sagemath like picture?http://ask.sagemath.org/question/39847/how-can-i-sketch-the-graph-in-sagemath-like-picture/I want sketch the coordinate sytstem and then sketch the circle in first area and like emoji(smile)( eyes=circle and mouth=triangle)
PLEASE HELP MEselinkirisThu, 30 Nov 2017 09:54:18 -0600http://ask.sagemath.org/question/39847/How to generate graphs random geometric shapes?http://ask.sagemath.org/question/38484/how-to-generate-graphs-random-geometric-shapes/ I would like to create practice problems, rather than reusing old exam questions, to help my students practice solving geometric problems. I would like to use sagetex to produce random variations similar the questions I have listed below. I would supply examples of the pictures, but I do not have enough points to post pictures.
I am wish to be able to make one worksheet where each time it is printed, the values would be randomly assigned and graph would be produced. I know how to assign a random integer value to a variable; however, how to produce the graphs I have no understanding of how to achieve that. Thus for each of the example problems how to make the graph and how to assign the random variability to that graph.
**Example questions**
*The diagram below shows a child’s toy which is made up of a circular hoop, centre O, radius 7 cm. The hoop is suspended in a horizontal plane by three equal strings XA, XB, and XC. Each string is of length 25 cm. The points A, B and C are equally spaced round the circumference of the hoop and X is vertically above the point O.*
- Calculate the length of XO.
- Find the angle, in degrees, between any string and the horizontal plane.
- Write down the size of angle AOB
- Calculate the length of AB.
- Find the angle between strings XA and XB.
*ABCDV is a solid glass pyramid. The base of the pyramid is a square of side 3.2 cm. The vertical height is 2.8 cm. The vertex V is directly above the centre O of the base.*
- Calculate the volume of the pyramid
- The glass weighs 9.3 grams per cm^3. Calculate the weight of the pyramid.
- Show that the length of the sloping edge VC of the pyramid is 3.6 cm
- Calculate the angle at the vertex, BVC
- Calculate the total surface are of the pyramid.
LaoshiSun, 06 Aug 2017 03:20:11 -0500http://ask.sagemath.org/question/38484/How to draw three pyramids inside a right prism?http://ask.sagemath.org/question/37814/how-to-draw-three-pyramids-inside-a-right-prism/ I want to draw three right pyramids, which together make up a prism. I want to see all the three right pyramids with different colors so that I can see them, and rotate in 3D?
`tetrahedron` is the function that I know, but I can't do it on my own. Or with any other 3D plot?screened00Tue, 06 Jun 2017 10:24:02 -0500http://ask.sagemath.org/question/37814/Intercept theorem in sagehttp://ask.sagemath.org/question/33330/intercept-theorem-in-sage/ Hi,
I'm working on Grobner bases and Buchberger algorithm and begginning in Sage. I would like to find a way to prove that if we have $B, C, D$ three points, then the point $C$ is in the circle of diameter $BD$ if and only if the triangle $BCD$ is an $C$-shaped right-angled triangle.
I'm thinking about using the Intercept theorem but I would like to prove it using Sage.
Thank you
interception47Fri, 06 May 2016 11:48:30 -0500http://ask.sagemath.org/question/33330/How does one use the qhull optional package?http://ask.sagemath.org/question/10254/how-does-one-use-the-qhull-optional-package/Has anyone used the qhull optional package? I'm not so sure on how to use it. Is there a tutorial on this?torrhoTue, 18 Jun 2013 14:22:00 -0500http://ask.sagemath.org/question/10254/Kernel dies when working with hyperplane arrangementhttp://ask.sagemath.org/question/35827/kernel-dies-when-working-with-hyperplane-arrangement/Following function causes kernel restart on any usage of "ha" (Sage 7.4, VirtualBox in Windows7 x64):
def f(n):
pos_vectors = [[1, 1, 1, 1], [1, -1, 1, 1], [1, 1, -1, 1], [1, -1, -1, 1], [1, 1, 1, -1], [1, -1, 1, -1], [1, 1, -1, -1], [1, -1, -1, -1]]
HA = HyperplaneArrangements(QQ, tuple("x" + str(i) for i in range(n)))
ha = HA([[tuple(vector), 0] for vector in pos_vectors])
print(ha.n_regions())
f(4)
Too simple use case for bug. Is there something that I miss?DSblizzardWed, 30 Nov 2016 13:25:12 -0600http://ask.sagemath.org/question/35827/transformation to lines and circleshttp://ask.sagemath.org/question/35516/transformation-to-lines-and-circles/I'd like to take a circle and apply a transformation to it (such as a reflection or a translation).
For instance, if T1 is translation 1 unit right and
c1 = circle((0,0),1),
I'd like to be able to plot T1(c1) (the image of c1 under T1, which is the circle with new center (1,0)).
How can I do this? Daniel LThu, 10 Nov 2016 21:34:40 -0600http://ask.sagemath.org/question/35516/Funny ellipsehttp://ask.sagemath.org/question/33447/funny-ellipse/ I am trying to plot an ellipse (using the term loosely). I want the set of points equidistant from the plane defined parametrically by (0, 0, 1) + t(0, 1, 1) + s(1, 1, 1).
It is intuitive that this is just the union of two parallel planes. But when I plot, I get an oval...what is wrong? Note that uncommenting to change the vectors gives two planes as expected, furthering my bewilderment.
posvec = vector([0, 0, 1])
# posvec = vector([1, 1, 1])
dirvec1 = vector([1, 1, 0])
# dirvec1 = vector([-1, 2, 0])
dirvec1 = dirvec1 / dirvec1.norm()
dirvec2 = vector([1, 1, 1])
# dirvec2 = vector([3, 0, -7])
dirvec2 = dirvec2 / dirvec2.norm()
point = vector([x, y, z])
relpos = point - posvec
disvec = relpos - relpos.dot_product(dirvec1) * dirvec1 - relpos.dot_product(dirvec2) * dirvec2
dis = disvec.norm()
radius = 10
my_ellipse = implicit_plot3d(10 - dis, (x, -15, 15), (y, -15, 15), (z, -15, 15), opacity = 0.3)
s, t = var('s, t')
my_focus = parametric_plot3d(posvec + t * dirvec1 + s * dirvec2, (t, -15, 15), (s, -15, 15), opacity = 0.3, color = 'red')
my_pic = my_focus + my_ellipse
my_picTumericTJWed, 18 May 2016 22:31:21 -0500http://ask.sagemath.org/question/33447/Sage: christoffel symbol calculation issue, help...http://ask.sagemath.org/question/32707/sage-christoffel-symbol-calculation-issue-help/I got this trying to compute the example christoffel symbols sage:
sage: var('r t theta phi')
(r, t, theta, phi)
sage: (r, t, theta, phi)
(r, t, theta, phi)
sage: sage: m = matrix(SR, [[(1-1/r),0,0,0],[0,-(1-1/r)^(-1),0,0],[0,0,-r^2,0],[0,0,0,-r^2*(sin(theta))^2]])
sage: sage: print m
[ -1/r + 1 0 0 0]
[ 0 1/(1/r - 1) 0 0]
[ 0 0 -r^2 0]
[ 0 0 0 -r^2*sin(theta)^2]
sage: [ -1/r + 1 0 0 0]
Moreover, I get...
sage: var('r t theta phi')
(r, t, theta, phi)
sage: m = matrix(SR, [[(1-1/r),0,0,0],[0,-(1-1/r)^(-1),0,0],[0,0,-r^2,0],[0,0,0,-r^2*(sin(theta))^2]])
sage: def christoffel(i,j,k,vars,g):
....: s = 0
....: ginv = g^(-1)
....: for l in range(g.nrows()):
....: s = s + (1/2)*ginv[k,l]*(g[j,l].diff(vars[i])+g[i,l].diff(vars[j])-g[i,j].diff(vars[l]))
....: return s
....:
File "<ipython-input-3-70e0eaa76f50>", line 6
return s
^
IndentationError: unindent does not match any outer indentation level
What am I doing BAD?
RiemanniumThu, 03 Mar 2016 15:19:04 -0600http://ask.sagemath.org/question/32707/interactive drawing and tikzhttp://ask.sagemath.org/question/9327/interactive-drawing-and-tikz/I would like to see something like this in sage:
-A graphic object that works similar to tikz and the result can be exported almost directly to tikz code.
-It also uses nodes that can be rendered in an interactive window so that all mathematical constructions are updated as you move the nodes, as in some geometry interactive software (like cabri or geometer sketchpad).
What could be a good way to get there? Which alternatives for rendering software might help?EmersonLMon, 17 Sep 2012 13:29:09 -0500http://ask.sagemath.org/question/9327/Computing the volume of a polytope that is not full-dimensionalhttp://ask.sagemath.org/question/10780/computing-the-volume-of-a-polytope-that-is-not-full-dimensional/Let us assume we are given a polytope in $\mathbb{R}^d$ which is $k$-dimensional. How can we compute its $k$-dimensional volume in Sage?SamsaTue, 26 Nov 2013 04:29:09 -0600http://ask.sagemath.org/question/10780/Number of line segments in a group - algorithmhttp://ask.sagemath.org/question/10252/number-of-line-segments-in-a-group-algorithm/Hi experts!
Im a newby SAGE, SciPy, Numpy and Python user.
I'm trying to write an algorithm that accounts for how many straight segment groups ('clusters') of a given dimension (dimension = number of lines that form the cluster).
Each line in my algorith is random-generated and characterized by his start point (xi,yi) and his end-point (xf,yf).
For example, in the image attached
http://subefotos.com/ver/?8818abc218ccd909f8c0bba71446c3b5o.png
there are: one cluster formed by 9 line segments, one cluster consists of four line segments, one cluster consists of five line segments, two cluster formed by three line segments, four cluster formed by two line segments and one cluster consists of one single line segments.
Until now i only could write a code that generates a matrix of NxN (where N = total number of line segments ). In this matrix, the element located in row A column B is 'True' if the segment A is cut with segment B, and its value is 'False' if that two segments are NOT intersect.
¿Any idea?
Waiting for your answers.
Thanks a lot!
mresimulatorTue, 18 Jun 2013 08:39:38 -0500http://ask.sagemath.org/question/10252/Sympy geometry: can't compute tangent lineshttp://ask.sagemath.org/question/9795/sympy-geometry-cant-compute-tangent-lines/Here's the problem:
from sympy import symbols, Plot
from sympy.geometry import *
c1 = Circle(Point(0,0),2)
a = Point(3,0)
at = c1.tangent_lines(a)
DomainError: can't compute a Groebner basis over RR
A little web search indicates that this was a problem with older versions of sympy, but Sage includes a newer version for which this issue is not supposed to be a problem. Any ideas on how to get round this?
AlasdairSun, 10 Feb 2013 17:36:34 -0600http://ask.sagemath.org/question/9795/Using pyglet in sage?http://ask.sagemath.org/question/9793/using-pyglet-in-sage/I'm experimenting with the Geometry package in sympy, but plotting seems to require pyglet:
from sympy import symbols, Plot
from sympy.geometry import *
c1 = Circle(Point(0,0),2)
Plot(c1)
ImportError: pyglet is required for plotting.
visit http://www.pyglet.org/
Now, as far as I know, pyglet is installed (via python), but it doesn't seem to be "visible" in Sage. I would rather use Sage than python/sympy, as I also need to perform some numerical and symbolic computations, as well as plotting the results.
So either I need to know how to get Sage to use pyglet, or get sympy.geometry to use another plotting tool.
Any advice? Thanks!AlasdairSat, 09 Feb 2013 22:59:47 -0600http://ask.sagemath.org/question/9793/Forming a solid from a set of intersecting planeshttp://ask.sagemath.org/question/9062/forming-a-solid-from-a-set-of-intersecting-planes/suppose I have equations of planes in 3D space in the form:
$A_ix + B_iy + C_iz = D_i$ for some values of i
**how can use sage to find the solid enclosed by them?** I need a plot of the surface of this solid. Actually I have many such sets of planes each forming a solid like this.(all concentric)
**For example:**
planes at x = -1, 1 in yz plane;
planes at y = -1, 1 in xz plane and planes at z = -1, 1 in xy plane intersect and form a unit cube centred at the origin.
ty ndomes!
But, its taking very long. I have like 12 or more equations (seen a maximum of 30 but can be more). I am now thinking of a different approach. We can easily make a function:
def inside(point , planes):
if the point is inside all the planes:
return 1
else:
return 0
so, now is there a good function in sagemath that can show all the region in space for which f(point) gives 1. (yea, its okay if the solids are filled as long as they're transparent enough. . Naively Taking lots of points and finding this solid(Like monte carlo) is very inefficient
Actually the program is taking very long time for these equations.
[-x - y - 1 == 0, -x - z - 1 == 0, -x + z - 1 == 0, -x + y - 1 == 0, -y- z - 1== 0, -y + z - 1 == 0, y - z - 1 == 0, y + z - 1 == 0, x - y - 1== 0, x - z - 1 == 0, x + z - 1 == 0, x + y - 1 == 0]
so, check it once. Thanks!ebsTue, 12 Jun 2012 04:26:42 -0500http://ask.sagemath.org/question/9062/How to triangulate polygon with sage?http://ask.sagemath.org/question/8857/how-to-triangulate-polygon-with-sage/If I feed sage a list of vertices, then the polygon() function can create a 2D polygon determined by visiting these edges in order (with self-intersections, repeated edges, holes, etc.).
Does sage have a built-in method to triangulate the resulting polygon? (It appears to me as though this is not the case.)
If not, I would love to see your homemade code to do this.
BillWed, 04 Apr 2012 18:56:02 -0500http://ask.sagemath.org/question/8857/New Project Looking for Help: Plotting great circleshttp://ask.sagemath.org/question/7785/new-project-looking-for-help-plotting-great-circles/Hi,
I'm working on a project and found that sage may be the best program to help. Information can be found at [vividdynamics.com](http://vividdynamics.com). I'm not a math student but study it as a hobby(mainly geometry) and have some art backround.
I'm looking for a way to generate a sphere with great circles plotted at cumulatively smaller intervals as they get closer to axis, x and y. Like I said, I'm not a math student so, I'm not sure how to define it in mathematical terms. basically it would look like an orange but with smaller and smaller pieces at, 90º, 180º, 270º, and 0º.
---
EDIT (niles):
Are you looking for formulas to parametrize these various great circles (so that you can plot them with sage)? If so, maybe rotation matrices are one easy way to produce them. You could start with a great circle whose parametrization you know (e.g. the one in the x-z plane) and then get others by rotating about the z-axis, say 45º, 67.5º, 78.75º, etc. Is that something like what you're looking for?
If so, the Wikipedia article for [rotation matrices](http://en.wikipedia.org/wiki/Rotation_matrix#Three_dimensions) looks useful. I believe you can plot parametric curves with sage, and apply arbitrary transformation matrices to them. For starters, here's a circle:
sage: u = var('u')
sage: parametric_plot3d( (cos(u), 0, sin(u)), (u, 0, 2*pi))
---
EDIT (dividenot):
Thanks for the reply. That sounds exactly what I'm looking to do. I must say though, I'm somewhat confused about the ask/answer system here. Initially I was looking for some kind of forum where I could have a discussion or look up any needed information but ask.sagemath.org was the closest thing I could find. Is editing the message like this the best way to have a discussion?
I looked at the Wikipedia article on rotation matrices. I suspect that SAGE doesn't have a command for rotation matrices so I would have to make an array defining my own range. And call the values of each circle from the matrix. Does that sound like a good way to go about it?dividenotWed, 01 Dec 2010 04:17:24 -0600http://ask.sagemath.org/question/7785/show polyhedron in an interacthttp://ask.sagemath.org/question/7718/show-polyhedron-in-an-interact/Hi, I am trying to write an interact which lets the user enter a list of vertices and then shows the corresponding polyhedron.
My first attempt is the following. The problem is that Sage does not show the polyhedron.
@interact
def _(t1=text_control("Polyhedron"), vertices="[[1,0],[0,1],[0,0]]"):
p=Polyhedron(vertices=eval(vertices))
show(p)
Does anybody know how to fix this?
Thanks.Philipp SchneiderFri, 01 Oct 2010 11:14:58 -0500http://ask.sagemath.org/question/7718/