Why does my code only create points instead of lines?

  • Context: Mathematica 
  • Thread starter Thread starter button_ger
  • Start date Start date
  • Tags Tags
    Lines Mathematica
Join the discussion
Registration is free. Ask a follow-up in this thread, or start your own.
2 replies · 2K views
button_ger
Messages
10
Reaction score
0
Hy Guys

I want to create some lines. That lines should be created by the solution of an equation. This equation has in my limits 1 or 2 solutions. The first euation is a circle.
The second is a line.

lineslope, radius, lineshift1, lineshift2 is defined before.

Code:
sol = Table[
  NSolve[{radius^2 == (x - radius)^2 + (y - radius)^2, 
    y == lineslope*x + i}, {x, y}]
  , {i, lineshift1, lineshift2, 20}]
Show[Graphics[Line[{{x, y}, {x, y}}]] /. sol]

This code only creates only points? Why? can anybody help me?

Greets
Jens
 
Physics news on Phys.org
I have solved the problem.

I changed ...
PHP:
sol = Table[
  NSolve[{radius^2 == (x - radius)^2 + (y - radius)^2, 
    y == lineslope*x + i}, {x, y}]
  , {i, lineshift1, lineshift2, 20}]
Show[Graphics[Line[{{x, y}, {x, y}}]] /. sol]

in...

PHP:
sol = Table[
  NSolve[{x,y}/.{radius^2 == (x - radius)^2 + (y - radius)^2, 
    y == lineslope*x + i}, {x, y}]
  , {i, lineshift1, lineshift2, 20}]
Show[Graphics[Line[sol]]]

This did it. But how is the replacing function working right to replace the Line[{{x,y},{x2,y2}}] correctly?
 
Last edited:
What you probably wanted in your original equation was:
Graphics[Line[{x, y} /. sol]]

I don't know how your new code is working for you, it failed for me.