Author |
Message |
|
wesley
Newbie
Joined: 05 May 2009 Posts: 45
|
Posted: 02 Mar 2010 01:47:34 pm Post subject: |
|
|
Okay, here is a fully working version (at least I think):
Code: Radian
ClrHome
Input "DY/DX ", Str1
String>Equ(Str1,Y1
FnOff
0.0325(Xmax-Xmin)→C
0.0325(Ymax-Ymin)→D
For(A,1,9
For(B,1,9
Xmin+B(Xmax-Xmin)/10→X
Ymax-A(Ymax-Ymin)/10→Y
Y1→M
tan-1(M→O
Line(Ccos(O)+X, Dsin(O)+Y, -Ccos(O)+X, -Dcos(O)+Y
End
End
Let me know if this works out right. |
|
Back to top |
|
|
meishe91
Newbie
Joined: 06 Dec 2009 Posts: 49
|
Posted: 02 Mar 2010 05:23:54 pm Post subject: |
|
|
Wesley wrote: Okay, here is a fully working version (at least I think):
Code: Radian
ClrHome
Input "DY/DX ", Str1
String>Equ(Str1,Y1
FnOff
0.0325(Xmax-Xmin)→C
0.0325(Ymax-Ymin)→D
For(A,1,9
For(B,1,9
Xmin+B(Xmax-Xmin)/10→X
Ymax-A(Ymax-Ymin)/10→Y
Y1→M
tan-1(M→O
Line(Ccos(O)+X, Dsin(O)+Y, -Ccos(O)+X, -Dcos(O)+Y
End
End
Let me know if this works out right.
For some reason it doesn't seem to do the correct field for dy/dx=x. I might have typed something in wrong though. Also, could you explain some of the math? I'm getting lost a little in it, just would like to know what's happening.
Also, here is my revised code. It still isn't perfect but it's better. The steep slopes don't look that good though, still working on it.
Code: ClrDraw
Input Str1
For(X,Xmin,Xmax
expr(Str1→M
For(B,Ymin,Ymax
MX+B→D
-D+(B+M(X+.35→E
D-(B+M(X-.35→F
Line(X+.35,B+E,X-.35,B-F
End
End
Hope Wesley and I are helping.
P.S. Mine works better at a closer window (like -5 to 5 on x and y and such).
Last edited by Guest on 01 Jul 2010 09:32:12 am; edited 1 time in total |
|
Back to top |
|
|
vanchagreen
Member
Joined: 20 Feb 2008 Posts: 136
|
Posted: 02 Mar 2010 06:47:14 pm Post subject: |
|
|
@Wesley: I'm not quite sure how to type String>Equ(Str1,Y1) , into the calculator...
@Meishe91: What are these lines for?
Code: -D+(B+(X+.35→E
D-(B+(X-.35→F
And thanks to both of you for all your help. |
|
Back to top |
|
|
meishe91
Newbie
Joined: 06 Dec 2009 Posts: 49
|
Posted: 02 Mar 2010 07:07:38 pm Post subject: |
|
|
vanchagreen wrote: @Wesley: I'm not quite sure how to type String>Equ(Str1,Y1) , into the calculator...
@Meishe91: What are these lines for?
Code: -D+(B+(X+.35→E
D-(B+(X-.35→F
And thanks to both of you for all your help.
String►Equ( is in the catalog. Just type "T" in the catalog and go up three, I believe.
Ok, that was my bad haha. They should have been -D+(B+M(X+.35→E and D-(B+M(X-.35→F. I fixed it in the post with the code so now that code should be correct haha. If you still want explanations then just say.
Last edited by Guest on 01 Jul 2010 09:32:35 am; edited 1 time in total |
|
Back to top |
|
|
vanchagreen
Member
Joined: 20 Feb 2008 Posts: 136
|
Posted: 02 Mar 2010 08:19:20 pm Post subject: |
|
|
I would still like explanations of the -D+(B+M(X+.35→E and D-(B+M(X-.35→F lines, please. |
|
Back to top |
|
|
meishe91
Newbie
Joined: 06 Dec 2009 Posts: 49
|
Posted: 02 Mar 2010 08:54:58 pm Post subject: |
|
|
Ok.
So the line MX+B→D is storing the y-value for the center of the line that will be generated. The next two lines (the ones you're asking about) are finding the y-values of X±.35 units. Then to obtain the right point, subtract D (The y-value of the center) from M(X+.35)+B. On the left side you subtract the value obtained from M(X-.35)+B from D. These basically give you two points that, when connected, create the slope line at the center point. You add B to these values in the Line( command to shift it all up into view. Hopefully that makes sense.
Last edited by Guest on 01 Jul 2010 09:33:14 am; edited 1 time in total |
|
Back to top |
|
|
vanchagreen
Member
Joined: 20 Feb 2008 Posts: 136
|
Posted: 02 Mar 2010 09:40:07 pm Post subject: |
|
|
Yes, thank you. Now all I've got to do is implement it. :biggrin: |
|
Back to top |
|
|
meishe91
Newbie
Joined: 06 Dec 2009 Posts: 49
|
Posted: 02 Mar 2010 09:59:53 pm Post subject: |
|
|
vanchagreen wrote: Yes, thank you. Now all I've got to do is implement it. :biggrin:
No problem. |
|
Back to top |
|
|
wesley
Newbie
Joined: 05 May 2009 Posts: 45
|
Posted: 02 Mar 2010 10:40:48 pm Post subject: |
|
|
Meishe91 wrote: For some reason it doesn't seem to do the correct field for dy/dx=x. I might have typed something in wrong though. Also, could you explain some of the math? I'm getting lost a little in it, just would like to know what's happening.
I looks like it works to me... (see attachment)
I am simply using the unit circle. All the math is within these two lines:
Code: tan-1(Y0→θ
Line(Ccos(θ)+X,Dsin(θ)+Y,‾Ccos(θ)+X,‾Dsin(θ)+Y
The X and Y are simply offsets to place the lines correctly. We have the derivative right? So if we take the arctangent of the function at that point, X, then we have the slope of the line. By this we can use Cos and Sin to get the correct angle at which the line resides. C and D are simply constants to create a specific size for the lines.
Last edited by Guest on 01 Jul 2010 09:33:38 am; edited 1 time in total |
|
Back to top |
|
|
meishe91
Newbie
Joined: 06 Dec 2009 Posts: 49
|
Posted: 02 Mar 2010 11:08:51 pm Post subject: |
|
|
Ok, I see what happened. You made a small typo in your code above. You put ...-Dcos(O)+Y instead of ...-Dsin(O)+Y. But I like your code better. Mine is smaller in size but yours solves the spacing issue mine has.
Last edited by Guest on 01 Jul 2010 09:34:05 am; edited 1 time in total |
|
Back to top |
|
|
wesley
Newbie
Joined: 05 May 2009 Posts: 45
|
Posted: 02 Mar 2010 11:41:57 pm Post subject: |
|
|
Meishe91 wrote: Ok, I see what happened. You made a small typo in your code above. You put ...-Dcos(O)+Y instead of ...-Dsin(O)+Y. But I like your code better. Mine is smaller in size but yours solves the spacing issue mine has.
I thought I had a bug in there somewhere!
Last edited by Guest on 01 Jul 2010 09:34:26 am; edited 1 time in total |
|
Back to top |
|
|
meishe91
Newbie
Joined: 06 Dec 2009 Posts: 49
|
Posted: 03 Mar 2010 12:10:31 am Post subject: |
|
|
Haha ya. Simple fix though |
|
Back to top |
|
|
thornahawk μολών λαβέ
Active Member
Joined: 27 Mar 2005 Posts: 569
|
Posted: 03 Mar 2010 07:12:03 pm Post subject: |
|
|
Expressions of the form cos(arctan(m)) and sin(arctan(m)) can be simplified to a form involving R►Pr(. :)
Thus,
Code: PROGRAM:SLPFLD
1→H \\ change this value to change the length of your line segments
Input "Y'=",Str0
Input "X STEPS: ",V
(Xmax-Xmin)/(V-1)→P
Input "Y STEPS: ",W
(Ymax-Ymin)/(W-1)→Q
DispGraph
For(J,0,W-1)
For(I,0,V-1)
Xmin+IP→X
Ymin+JQ→Y
expr(Str0)→M
HΔX/R►Pr(1,M)→R
Line(X-R,Y-MR,X+R,Y+MR)
End:End
thornahawk
Last edited by Guest on 03 Mar 2010 07:29:46 pm; edited 1 time in total |
|
Back to top |
|
|
Bhaliar
Member
Joined: 16 Nov 2009 Posts: 221
|
Posted: 03 Mar 2010 09:29:07 pm Post subject: |
|
|
I know you already figure it out, and I'm con fused cause I'm still in pre-calc, but wouldn't it be easier to get the slope and then check points against the slope. Change in y over the change in x? |
|
Back to top |
|
|
wesley
Newbie
Joined: 05 May 2009 Posts: 45
|
Posted: 03 Mar 2010 10:06:25 pm Post subject: |
|
|
Bhaliar wrote: I know you already figure it out, and I'm con fused cause I'm still in pre-calc, but wouldn't it be easier to get the slope and then check points against the slope. Change in y over the change in x?
That's essentially what my program is doing.
But all this doesn't matter unless you are in Calculus!!! :biggrin: |
|
Back to top |
|
|
meishe91
Newbie
Joined: 06 Dec 2009 Posts: 49
|
Posted: 03 Mar 2010 11:30:58 pm Post subject: |
|
|
Bhaliar wrote: I know you already figure it out, and I'm con fused cause I'm still in pre-calc, but wouldn't it be easier to get the slope and then check points against the slope. Change in y over the change in x?
Same here, that's basically what mine does too. It finds the slope, then plots two points that create a line on the slope line. If that makes sense haha.
By the way, Thornahawk, could you explain your code a little?
Last edited by Guest on 03 Mar 2010 11:43:25 pm; edited 1 time in total |
|
Back to top |
|
|
IAmACalculator In a state of quasi-hiatus
Know-It-All
Joined: 21 Oct 2005 Posts: 1571
|
Posted: 04 Mar 2010 06:13:18 pm Post subject: |
|
|
Graph3 also has this feature, but I don't know how it compares to these basic versions, and you probably don't need an entire APP for something like this. But just in case... |
|
Back to top |
|
|
thornahawk μολών λαβέ
Active Member
Joined: 27 Mar 2005 Posts: 569
|
Posted: 04 Mar 2010 06:58:19 pm Post subject: |
|
|
@meishe:
Instead of giving you the whole caboodle, I'll leave you the fun of figuring it out. First, a picture:
The line segment in the picture obviously has the slope m. What should the value of x be such that the length of the segment is h? (Hint: Pythagoras may be of service).
Shift the origin such that the line segment starts at an arbitrary point, and you have the formulae in my program.
thornahawk |
|
Back to top |
|
|
meishe91
Newbie
Joined: 06 Dec 2009 Posts: 49
|
Posted: 04 Mar 2010 08:54:16 pm Post subject: |
|
|
Well I was following, kinda haha, up until you said what x has to be so the length is h. Just not seeing what h is.
Last edited by Guest on 01 Jul 2010 09:35:06 am; edited 1 time in total |
|
Back to top |
|
|
Bhaliar
Member
Joined: 16 Nov 2009 Posts: 221
|
Posted: 04 Mar 2010 09:49:41 pm Post subject: |
|
|
Well I will be in calculus next year, so.. That and I think h is the height from the point X'y at the top to the point x,0 on the x axis. It uses pythagorean therom to do th test? |
|
Back to top |
|
|
|