4
$\begingroup$

Please can you advise me how to speed up the rendering of the following two planes? When I click and drag to rotate the plot, its movement is quite jerky. Presumably it is working harder than I need it to. The matrix equation A.X = B represents two flat planes embedded in 3D space. The solution of the system is the line of intersection of the two planes. I believe ContourPlot3D interprets the matrix equation as a list of the two planes. In fact, A.X == B evaluates as {{x + y + z}, {x - y + 2 z}} == {{4}, {0}}.

A = {{1, 1, 1}, {1, -1, 2}};
B = {{4}, {0}};
X = {{x}, {y}, {z}};
ContourPlot3D[A.X == B, {x, -10, 10}, {y, -10, 10}, {z, -10, 10}, 
ContourStyle -> Directive[Opacity[.6]], MeshStyle -> Gray]

I have tried using Evaluate on the expression A.X == B, and on the expression A.X, but to no avail.

You might think it better to separate the two planes, and use Plot3D command for each, but I would like my code to work automatically for general linear systems, i.e., for different choices of A, B and X, and I would like it to accomodate vertical planes, to which I guess Plot3D would not apply.

$\endgroup$

1 Answer 1

7
$\begingroup$

You need to get rid of some extraneous List wrappers

A = {{1, 1, 1}, {1, -1, 2}};
B = {4, 0};
X = {x, y, z};

and then thread the two sides of your matrix equation over Equals.

ContourPlot3D[Evaluate @ Thread[A.X == B], {x, -10, 10}, {y, -10, 10}, {z, -10, 10}, 
  ContourStyle -> Opacity[.6], MeshStyle -> Gray]

plot

The graphics shown above rotate in a nice, smooth fashion.

$\endgroup$
1
  • $\begingroup$ Thank you very much, @m_goldberg ! That is great. I know Mathematica's Dot command cleverly interprets vectors as row or column vectors depending on the context. I had hoped to insist that my column vectors be represented as nx1 matrices but I guess it is not important. I tried forcing this using Evaluate[Thread[Map[Flatten, Map[Transpose, A.X == B]]]] for the function in the first argument of ContourPlot3D but ContourPlot3D still didn't want to play ball. Do you have any idea why ? $\endgroup$
    – Simon
    Sep 24, 2015 at 12:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.