QB64.org Forum
Active Forums => QB64 Discussion => Topic started by: lomalena on February 29, 2020, 08:05:09 am
-
Hello, I'm new in qb64 and we are using this in our master's degree classes. Since I'm an architect and programming is very hard for me to understand.
I have a question that I cannot figure it out.
For example, I have a function lets say f(x)=sin(x)+5
I want to divide that function into random 4 pieces and I want to find the coordinates of the points which cut the function.
I started like this but I don't know how to solve it.
Can someone plz help? Thank you.
OPTION _EXPLICIT
DIM m AS INTEGER
INPUT "how many pieces should we divide", m
DIM n AS INTEGER
FUNCTION fx (x AS DOUBLE)
fx = SIN(x) + 5
FOR
NEXT
END FUNCTION
well I have no idea that what I am doing.
-
Are you asking for the coordinates of the blue diamonds given random x1 x2 x3 etc? See below.
-
_TITLE "Quick SIN Plot" 'b+ 2020-02-29 SCREEN _NEWIMAGE(1000, 600, 32) ' 800 x 600 window allowing graphics ie 32 bit color or RGB and RGBA amplitude = 200
'lets plot sin(x)
y
= yCenter
+ amplitude
* SIN(_D2R(x
)) '_D2R is a degrees to Radians functionINPUT "How many points along x axis "; xPts
x
= RND * (_WIDTH - 350) ' rand x on screen's x axis y
= yCenter
+ amplitude
* SIN(_D2R(x
))
EDIT: fix location
-
Thank you so much :D
I think I understand now. I will try to make it more simple maybe :D Thank you so much!