|
Post by hartnell on May 25, 2007 12:38:57 GMT -5
No matter what I do, DegToRad() comes up with a type mismatch. Secondly, I realize that it's in the math object, but since the graphics.SetAngle method only accepts bizzare radians, noobs really need this error free. I'm writing the code for the "How to Rotate an Image" page and it's frustrating even me.
--hartnell
|
|
|
Post by Guilect on May 25, 2007 13:12:35 GMT -5
I will look into the math object DegToRad function when I get a chance. For those who would like to understand it a bit more here is some info form Lucky\'s VB site : rookscape.com/vbgaming/tutBK.phpDegrees and radians Now I don?t know about you, but when I measure an angle, I measure it in degrees. Well VB measures angles in Radians. With radians, there are 2pi of them in a circle. So: 2pi radians = 360 degrees. With that cleared up, we might want to write some functions to convert between radians and degrees. The first thing I will point out is that because VB uses radians to give angles, we can get a pretty accurate version of pi by using this formula: Pi = Atn(1) * 4 Which equals: 3.14159265358979. That should be accurate enough for our needs Now if you are in my target audience, then you probably don?t know how or why this works, but by the end of the tutorial, I hope you do. So to get radians from degrees: Function DegToRad(Degrees) DegToRad = Degrees / 180 * Pi End Function And the opposite: Function RadToDeg(Radians) RadToDeg = Radians * 180 / Pi End Function
|
|
|
Post by hartnell on May 25, 2007 13:26:31 GMT -5
See, that's exactly my point.
You have the power to make the method accept degrees instead of radians.
--hartnell
|
|
|
Post by Guilect on May 25, 2007 13:34:44 GMT -5
Not sure what you are seeing with the DegToRad function.
It seems to work, for example:
foo = 90
system.debugPrint math.DegToRad(foo)
system.debugPrint math.DegToRad(90)
system.debugPrint myDegToRad(foo)
Function myDegToRad(Degrees)
myDegToRad = Degrees / 180 * Pi
End Function
I could change the parameter input value to degrees from radians, but 1.) I believe it is more traditional to be in radians 2.) It already is in radians and changing it could break existing code.
So, how about this, maybe I add a new command that accepts degrees, e.g. graphics.SetAngleD
Thoughts...
|
|
|
Post by hartnell on May 25, 2007 13:40:06 GMT -5
I was using the standard RadToDeg() NOT in the math object. it appears in the syntax highlighter.
--hartnell
|
|
|
Post by Guilect on May 25, 2007 14:04:16 GMT -5
Don\'t believe that there is a \'standard\' function for that.
Either use the function provided above or put \"Math.\" in front of the command and you will be fine.
|
|
|
Post by hartnell on May 25, 2007 14:05:29 GMT -5
Sorry, by syntax highlighter I meant "auto completer" --hartnell
|
|
|
Post by Guilect on May 25, 2007 14:24:28 GMT -5
ya the autocomplete is not the smartest, it hinks that you already typed \"math.\".
(Speaking of not the smartest, this darn proxy server that I go through is always converting apostophes into slashes)
|
|
|
Post by u9 on May 26, 2007 5:07:42 GMT -5
I could change the parameter input value to degrees from radians, but 1.) I believe it is more traditional to be in radians 2.) It already is in radians and changing it could would break existing code. 3.) This would also break "compatibility" with the remaining functions available in VB such as sin(), cos() etc. So, how about this, maybe I add a new command that accepts degrees, e.g. graphics.SetAngleD Thoughts... Well if you make a copy of this command for degrees then you should probably also make other angle-commands do the same. Many of these commands already reside inside the math object which will require the person to register Brutus2D anyway, so point half lost. Another problem is the remaining functions, e.g. sin(), cos() which are already in VBscript. These should in my opinion also have a degree-counterpart. I think all these functions clutter too much but then again i do prefer radians :$ If the math object was free problem would be solved as the DegToRad() function would be available to the target audience (newcomers) of the tutorial and no function needed to be cloned. But we do want people to buy B2D so that is not a solution. But then we are back to square 1 with hartnell's newbie-problem. One way to solve it is to just use radians and note that a circle is actually 2pi. Another way is to tell the unregistered users (probably most of the tutorial readers ) to copy and paste the function into their code as-well. That is a bit annoying i know I do see Hartnell's dilemma. I don't know about you guys but I learned in school that a circle was 360 degrees and first learned radians later on so this is probably true for others too. And the target audience for Brutus2D is these hobbyist programmers. What to do what to do... Maybe i should stop babbling now
|
|