@cheleball, on Feb 27 2007, 05:24 PM, said in SketchMapMerge Shapes:
I knew someone would say something about that. You just couldn't resist, could you?
Look, we run a MAMP shop where I work, so PHP is what I write web pages with every day. I don't know Python or Ruby or Perl, but I know me some PHP, and by golly, it gets the job done just the same.
Sounds like a great way to get a sinusoid, but again, how would that get me a cycloid? (I know you're being pragmatic, but getting a shape that looks like a cycloid but is not one just doesn't tick that checkbox next to the goal in my brain that says, "make a cycloid." ;))
As for the source of the bad rotation angles, I figure it could be one of three things:
-
Roundoff errors in the calculation (the angles are a bit too far off for this to be the case IMO, and also, they're off by the same amount in successive cycloids, which would tend to point away from roundoff error).
-
The angle is calculated for the center of the sprite and not its rightmost edge.
-
There's something about the way SMM works that I don't understand.
I hope the true cause is really on that list. Now I just need to figure out which it might be...
FYI, the "base" is a map file with just a wasteland wall short, sized 84x46 and positioned with its center at the origin, with the "in" side facing right. I calculate the rotation angle as the angle between the line determined by the two points found in the cycloid calculation and the y-axis. (BTW, I replaced the switch statement with a single line that takes advantage of the fact that a β’ b = abcos(theta), but the result is exactly the same. :()
lol - well, I've done a fairly huge amount of php too, and have developed a loathing for the language. There's just no consistency in the API's (haystack, needle, or vice-versa?) - the way references work is insanely broken, there's no decent type and safety checking - not even any scoping like perl's 'use strict' to catch variable name typos... It's just... ugh... my shining star example of terrible open-source
But... I use it nonetheless because so many people I do websites in my spare time for insist on it. Seems to be a mantra these days... "must... have... php.... ajax... javascript... web2 ... other-marketing-buzzword-which-I-don't-know-what-it-means-but-I-want-it-anyway!"
However (as with most languages - it's whatever works best for you. I've done a limited amount of python, insanely huge (10's of thousands of lines of object-orientated perl - yeah, OO-perl 5 it is possible... sort of... ), but no ruby. I do want to try ruby-on-rails at some point, if I can only be bothered to sit down and learn it.
Then there's the more traditional c (and 'newer' c99),c++, obj-c, haskell, java and such. But... gah, they all seem so low level after using scripting languages.
So I'm somewhat multi-lingual, and therefore feel I have a right to slate php
but moving on...
@cheleball, on Feb 27 2007, 05:24 PM, said in SketchMapMerge Shapes:
Sounds interesting, but I don't understand how it would yield a cycloid. Would you mind being a bit more specific?
Well, to me (and apologies if I've got the wrong end of the stick, a 'cycloid' is a something that looks quite like
y = abs( sin(x) )
i.e. (using macos x's wonderful grapher program), assuming no tweaking of he constants that define it.
y_abs_sin_x.png (19.43K)
Number of downloads: 7
the difference being on the gradient differential - a cycloid looks like it is about to go asymptotic where it crosses the axis, whilst this does not (the gradient is moving towards 1 as it crosses the axis. Of course, if you take a more general formula:
y=n*abs(sin(m*x))+c
then 'n' gives a height scale factor,
'm' gives a frequency scale factor
and
'c' gives an offset (probably not useful here)
The partial circle idea solves this neatly, but still suffers from having discontinuities where the step function kicks in and moves you from right-hand edge of one circle to left-hand edge of the next....
Moving on...
However... if you want to make a 'real' cycloid, you've got to go parametric. I'm assuming you know about radians rather than degrees when doing graphs (it makes things easier) - so you want an equation along the lines of (where 't' is in radians)
x = at - h sin(t), y = a - h cos(t)
Which when plotted will give you a cycloid. e.g. I did in the grapher for this image with t running from 0 to 6*PI: (PI radians = 180 degrees = 1/2 a circle, if you prefer using degrees)
parametric.png (11.2K)
Number of downloads: 4
again, you can play with the constants (both taken as '1') to adjust it. If 'h' > 'a' then you will see that you make loops rather than 'points' between the main curves which look quite pretty but aren't in this use case very interesting for this application. Try it in the grapher program and see what takes your fancy. Finally, there's the special case where 'a' = 0, which as you can probably tell, will give you your normal circle, radius, 'h' centred on the origin.
Ah... my A-level maths is all coming back to me
(edited for some typos in my anti-php rant)
This post has been edited by Crono : 27 February 2007 - 06:03 PM