of     1   

Gorake
#125857504Sunday, February 16, 2014 6:31 AM GMT

Hey, so I've made a very basic, very rough graphing program at my place. Problem 1 is when you graph something like math.tan(x), it connects the points which shouldn't be connected, through the asymptotes, with a line. Problem 2 arises when graphing something like math.abs(x-0.25), which should have a sharp point, but flattens out. Ideas for fixing either of those? Here's the place if you need a visual: http://www.roblox.com/Graphing-with-GUIs-place?id=145753868
MettaurSp
#125857751Sunday, February 16, 2014 6:36 AM GMT

Why did you post a help request here when there is poor little forgotten Scripting Helpers over there? www.roblox.com/Forum/ShowForum.aspx?ForumID=20
Gorake
#125857841Sunday, February 16, 2014 6:37 AM GMT

Sorry, I didn't really think this question would be answered over there very well. I'll post there too, though.
Brandonhare
#125898258Sunday, February 16, 2014 7:02 PM GMT

Detecting asymptotes and other discontinuities from user functions is pretty difficult. To solve your first problem, perhaps only draw a line between points if they're both in the viewing area. If your point resolution is good enough, I think this would only affect the vertical lines you're trying to avoid. Maybe you could also detect if the points have opposite signs or have a very large difference between them. I'd also recommend increasing the point resolution to help smooth things out and lessen the effects of any inaccurate results. People often assign a fixed number of points along the x-axis, when really it should match the curve of the function. For example, a steep line between (0,0) and (1,10) would only get 2 points, whereas an equal length line between (0,0) and (10,1) would get 11 points. I'd dynamically assign more points if I measure the gradient of the function to be steep in that area (assuming you're not doing this already). This would also improve my first idea as it would remove some false-positives, leaving only a single sharp line between two points which is more obvious as an unwanted asymptote.
Gorake
#125898526Sunday, February 16, 2014 7:05 PM GMT

The gradient checking idea is a good one, thanks!
Waterlimon
#125902584Sunday, February 16, 2014 7:42 PM GMT

Hard code the locations of sign flip for different mathematical operators and create a fancy function analyzer to find continuous ranges of the functions.

    of     1