Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Mathematica 7 lines, solution

  1. Feb 22, 2010 #1
    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 (Text):
    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
     
  2. jcsd
  3. Feb 24, 2010 #2
    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: Feb 24, 2010
  4. Feb 26, 2010 #3

    Dale

    Staff: Mentor

    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.
     
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook