Student Support Forum: 'Defining a query -- Is point P in plane Q?' topicStudent Support Forum > General > "Defining a query -- Is point P in plane Q?"

 Next Comment > Help | Reply To Topic
 Author Comment/Response Erin Glaser Arlinghaus 11/30/99 3:38pm I thought this would be simple, but I have a persistent problem: I'm trying to define a query, called InThePlaneQ, to test whether a given point lies in a plane defined by a given equation in {x,y,z}. Every time I call the function, it gives the correct answer the SECOND time I call it with the same arguments, but not the first time. I'm assuming this is due to Mathematica retaining the ''old'' assignments from the last time the function was called, but I'm not sure how to fix it simply. Here's the relevant code. It first defines the query; gives a list ''vertices'' of points; gives a list ''planes'' of equations; and then gives the form of the query, selecting one of the points and testing whether it lies in the chosen plane. --------------------------------------------------------------- InThePlaneQ[vec_, eqn_] := {x = vec[[1]]; y = vec[[2]]; z = vec[[3]]; eqn}[[1]] vertices:={{-0.134333, -0.134333, -0.134333}, {-0.134333, -0.134333, 0.134333}, {-0.134333, 0.134333, -0.134333}, {-0.134333, 0.134333, 0.134333}, {0.134333, -0.134333, -0.134333}, {0.134333, -0.134333, 0.134333}, {0.134333, 0.134333, -0.134333}, {0.134333, 0.134333, 0.134333}} planes:=\!\({0.4029979885041174`\ x + 0.`\ y + 0.`\ z == x\^2 + y\^2 + z\^2, 0.`\ x + 0.4029979885041174`\ y + 0.`\ z == x\^2 + y\^2 + z\^2, 0.`\ x + 0.`\ y + 0.4029979885041174`\ z == x\^2 + y\^2 + z\^2, \(-0.4029979885041174`\)\ x + 0.`\ y + 0.`\ z == x\^2 + y\^2 + z\^2, 0.`\ x - 0.4029979885041174`\ y + 0.`\ z == x\^2 + y\^2 + z\^2, 0.`\ x + 0.`\ y - 0.4029979885041174`\ z == x\^2 + y\^2 + z\^2} InThePlaneQ[vertices[[1]], planes[[1]]] InThePlaneQ[vertices[[7]], planes[[1]]] --------------------------------------------------- Now the answer to the first query should be False, and the answer to the second query should be True, but these are not always the answers that I get! If I run each one twice it's always correct the second time! Can you help me get around this? URL: ,

 Subject (listing for 'Defining a query -- Is point P in plane Q?') Author Date Posted Defining a query -- Is point P in plane Q? Erin Glaser ... 11/30/99 3:38pm Re: Defining a query -- Is point P in plane Q? Aaron Honecker 12/02/99 06:39am
 Next Comment > Help | Reply To Topic