Python Forum
Same line length in slope fields
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Same line length in slope fields
#2
You need to define line length first.


from pylab import plt, np
def f(x,y):
    return -y/x

line_len = 0.2

for m in [i for i in range(-4,5) if i!=0]:
    for n in [i for i in range(-4,5) if i!=0]:
        slope=f(m/2,n/2)
        slope = np.arctan(slope)   # we need to clarify what slope means, is it an angle? or tan(angle)? what do we want?
        plt.plot([m/2,m/2+line_len * np.cos(slope)],[n/2,line_len * np.sin(slope)+n/2],color='k')
        plt.ylim(-2,2,1/2)
        plt.xlim(-2,2,1/2)
        plt.grid(True)
Reply


Messages In This Thread
Same line length in slope fields - by schniefen - Apr-24-2019, 01:07 AM
RE: Same line length in slope fields - by scidam - Apr-24-2019, 04:37 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  split the line fixed length tokens bb8 5 5,641 Nov-25-2017, 06:18 PM
Last Post: heiner55

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020