This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#51 2010-06-21 21:56:56

cds56
Scratcher
Registered: 2008-05-02
Posts: 500+

Re: Trigonometry Help

nXIII wrote:

shadow_7283 wrote:

nXIII is smarter than everybody.  tongue

tongue
Nah, I've just been using trig for a couple of years and in a lot of different things. Practice makes perfect!

It still appears that you're smarter than the vast majority of the active scratch community.

Except for me of course.

I'm smarter than everyone here.

But not in smalltalk.

Speaking of trig, I was looking into it, and it seems like a whole whack of fun. (that is, if you find math and advanced stuff like that fun... )


http://img192.imageshack.us/img192/909/meowdevlogo.pnghttp://i32.tinypic.com/pucti.png

Offline

 

#52 2010-06-22 04:58:03

juststickman
Scratcher
Registered: 2009-05-31
Posts: 1000+

Re: Trigonometry Help

Greatdane wrote:

juststickman wrote:

Has anyone realized that you can just use point towards block, record the angle and them go back to the original direction?
If it has to use trig, copy the point towards script >.>

But we want to use advanced formulas and trigonometry!  sad

Fine then.
http://wiki.scratch.mit.edu/images/Point_Towards_Background.gif


http://is.gd/iBQi2 Add grob to your sig and help with world dominiation!http://is.gd/iBQ9Q                                                             Hey guys, we're seriously naming our team bob?

Offline

 

#53 2010-06-22 09:34:53

shadow_7283
Scratcher
Registered: 2007-11-07
Posts: 1000+

Re: Trigonometry Help

You got that from the Scratch Wiki. That's cheating...

Plus, as I said before...

shadow_7283 wrote:

But that would require another sprite! And let's face it, who wants THAT? Plus, I needed the degrees listed from 1-360 AND in the Scratch format.

Last edited by shadow_7283 (2010-06-22 09:37:03)

Offline

 

#54 2010-06-22 09:36:36

MathWizz
Scratcher
Registered: 2009-08-31
Posts: 1000+

Re: Trigonometry Help

Oh... Yeah! LOL!


http://block.site90.net/scratch.mit/text.php?size=30&text=%20A%20signature!&color=333333

Offline

 

#55 2010-06-22 11:51:45

markyparky56
Scratcher
Registered: 2008-03-20
Posts: 1000+

Re: Trigonometry Help

shadow_7283 wrote:

You got that from the Scratch Wiki. That's cheating...

Plus, as I said before...

shadow_7283 wrote:

But that would require another sprite! And let's face it, who wants THAT? Plus, I needed the degrees listed from 1-360 AND in the Scratch format.

What about putting it in the background and it returns a variable?


http://j.mp/jgVnTq
Check out my game engine development site: NewDawn I'm a Level 171 Scratcher.I am http://bit.ly/nkvLNT

Offline

 

#56 2010-06-22 12:17:14

Subh
Scratcher
Registered: 2010-05-25
Posts: 100+

Re: Trigonometry Help

GREAT WORK NXIII

How old are you?I'm 15


http://wiki.scratch.mit.edu/skins/scratch/logo.png     I'M IN Scratch Wiki .... ARE YOU ????

Offline

 

#57 2010-06-22 16:50:41

cds56
Scratcher
Registered: 2008-05-02
Posts: 500+

Re: Trigonometry Help

Subh wrote:

GREAT WORK NXIII

How old are you?I'm 15

nXIII is approximately eight years old.

jk, I don't know really. I would guess that he's around 13 - 16 though..


http://img192.imageshack.us/img192/909/meowdevlogo.pnghttp://i32.tinypic.com/pucti.png

Offline

 

#58 2010-06-22 17:58:40

nXIII
Community Moderator
Registered: 2009-04-21
Posts: 1000+

Re: Trigonometry Help

cds56 wrote:

Subh wrote:

GREAT WORK NXIII

How old are you?I'm 15

nXIII is approximately eight years old.

jk, I don't know really. I would guess that he's around 13 - 16 though..

...eight?

I'm younger than Subh. But I've been using trig for a while, I don't want to sound like I'm bragging or anything (I'm hope it doesn't sound like I am)


nXIII

Offline

 

#59 2010-06-22 19:29:10

billyedward
Scratcher
Registered: 2008-01-03
Posts: 500+

Re: Trigonometry Help

You guys are WAY overthinking this!
Just remember that the TAN function takes an angle, and converts it to a slope.
Therefore, atan converts slope to angle.
We can get the slope using rise/run, or in this case
(mouseY-[y of centre of circle]) / (mouseX-[x of centre of circle]).
It follows, then, that the angle is:
aTan((mouseY-[y of centre of circle]) / (mouseX-[x of centre of circle]) ).

Just remember the trigonometric ratios:

http://img130.imageshack.us/img130/383/aho.gif
Tan(Θ)=Opposite/Adjacent
Sin(Θ)=Opposite/Hypotenuse
Cos(Θ)=Adjacent/Hypotenuse

In this case, theta is the angle of the 'line' you mentioned.
That line is the hypotenuse.
The Adjacent (X) and Opposite (Y) are derived using the subtraction shown above.
We then use the tan to get theta, and move the tan over to the other side to isolate it.

Understand?

Last edited by billyedward (2010-06-22 19:29:55)


"I'd love to change the world, but they haven't released the source code yet."
Check out the latest version of Streak --> http://billy.scienceontheweb.net/Streak

Offline

 

#60 2010-06-22 19:42:13

shadow_7283
Scratcher
Registered: 2007-11-07
Posts: 1000+

Re: Trigonometry Help

Billyedward is smarter than nXIII.  tongue

Offline

 

#61 2010-06-22 19:54:31

cds56
Scratcher
Registered: 2008-05-02
Posts: 500+

Re: Trigonometry Help

shadow_7283 wrote:

Billyedward is smarter than nXIII.  tongue

Regarding which aspects of intelligence?

Developmentally speaking, nXIII's brain hasn't even finished developing yet. If he is indeed younger than fifteen.

So remarking their current levels of "intelligence" ( The factors our current society perceives as relating to intelligence.) billyedward would probably be "smarter" than nXIII.

Who am I to judge someone else's intelligence?

tongue
pfft


http://img192.imageshack.us/img192/909/meowdevlogo.pnghttp://i32.tinypic.com/pucti.png

Offline

 

#62 2010-06-22 20:13:36

shadow_7283
Scratcher
Registered: 2007-11-07
Posts: 1000+

Re: Trigonometry Help

I wasn't trying to be technical. It was a joke. Hence the  tongue

Offline

 

#63 2010-06-22 21:07:32

billyedward
Scratcher
Registered: 2008-01-03
Posts: 500+

Re: Trigonometry Help

Well, I wouldn't say that it can be definitively deduced from the scratch forums who is smarter... And I have seen many of the things that nXIII has done, and I must say that he is certainly of a superior intellect to many of us. (who exactly, will remain unnamed)

The other thing to consider is that he is under 15, and older than 8. So we know him to be between the ages of 9 and 14. I on the other hand, am exactly 15. Therefore, on an IQ basis, even if we scored the exact same on a test his would be higher. This must be taken into account on the scratch forums, too.

But shadow_7283, I take your above comment to mean that my solution worked?


"I'd love to change the world, but they haven't released the source code yet."
Check out the latest version of Streak --> http://billy.scienceontheweb.net/Streak

Offline

 

#64 2010-06-22 21:32:36

MathWizz
Scratcher
Registered: 2009-08-31
Posts: 1000+

Re: Trigonometry Help

billyedward wrote:

Well, I wouldn't say that it can be definitively deduced from the scratch forums who is smarter... And I have seen many of the things that nXIII has done, and I must say that he is certainly of a superior intellect to many of us. (who exactly, will remain unnamed)

The other thing to consider is that he is under 15, and older than 8. So we know him to be between the ages of 9 and 14. I on the other hand, am exactly 15. Therefore, on an IQ basis, even if we scored the exact same on a test his would be higher. This must be taken into account on the scratch forums, too.

But shadow_7283, I take your above comment to mean that my solution worked?

It works for the first quadrant only. Atan2 would work for all four quadrants. It also makes the sprite point in the wrong direction due to Scratch's weird angles. With some tweaking it can be made perfect!  smile

Last edited by MathWizz (2010-06-22 21:36:01)


http://block.site90.net/scratch.mit/text.php?size=30&text=%20A%20signature!&color=333333

Offline

 

#65 2010-06-22 21:51:43

nXIII
Community Moderator
Registered: 2009-04-21
Posts: 1000+

Re: Trigonometry Help

MathWizz wrote:

billyedward wrote:

Well, I wouldn't say that it can be definitively deduced from the scratch forums who is smarter... And I have seen many of the things that nXIII has done, and I must say that he is certainly of a superior intellect to many of us. (who exactly, will remain unnamed)

The other thing to consider is that he is under 15, and older than 8. So we know him to be between the ages of 9 and 14. I on the other hand, am exactly 15. Therefore, on an IQ basis, even if we scored the exact same on a test his would be higher. This must be taken into account on the scratch forums, too.

But shadow_7283, I take your above comment to mean that my solution worked?

It works for the first quadrant only. Atan2 would work for all four quadrants. It also makes the sprite point in the wrong direction due to Scratch's weird angles. With some tweaking it can be made perfect!  smile

Which is the basis on which my algorithm is made. I just used arccosine because there is a smaller chance of division by zero when using the hypotenuse.


nXIII

Offline

 

#66 2010-06-23 01:26:10

billyedward
Scratcher
Registered: 2008-01-03
Posts: 500+

Re: Trigonometry Help

nXIII wrote:

MathWizz wrote:

billyedward wrote:

Well, I wouldn't say that it can be definitively deduced from the scratch forums who is smarter... And I have seen many of the things that nXIII has done, and I must say that he is certainly of a superior intellect to many of us. (who exactly, will remain unnamed)

The other thing to consider is that he is under 15, and older than 8. So we know him to be between the ages of 9 and 14. I on the other hand, am exactly 15. Therefore, on an IQ basis, even if we scored the exact same on a test his would be higher. This must be taken into account on the scratch forums, too.

But shadow_7283, I take your above comment to mean that my solution worked?

It works for the first quadrant only. Atan2 would work for all four quadrants. It also makes the sprite point in the wrong direction due to Scratch's weird angles. With some tweaking it can be made perfect!  smile

Which is the basis on which my algorithm is made. I just used arccosine because there is a smaller chance of division by zero when using the hypotenuse.

I see...
That does make sense.
Let me go and revise mine, then, to fix this.


"I'd love to change the world, but they haven't released the source code yet."
Check out the latest version of Streak --> http://billy.scienceontheweb.net/Streak

Offline

 

#67 2010-06-23 01:49:35

billyedward
Scratcher
Registered: 2008-01-03
Posts: 500+

Re: Trigonometry Help

Ok, I fixed it.
Here is the XML code for the working block:

Code:

<?xml version="1.0" encoding="UTF-8" ?><scratchScript><block selector="-"><argument><block selector="+"><argument>-90</argument><argument><block selector="*"><argument>90</argument><argument><block selector="*"><argument><block selector="-"><argument><block selector="computeFunction:of:"><argument>abs</argument><argument><block selector="-"><argument><block selector="\\"><argument><block selector="+"><argument><block selector="rounded"><argument><block selector="computeFunction:of:"><argument>10 ^</argument><argument><block selector="+"><argument><block selector="-"><argument><block selector="mouseX"/></argument><argument><block selector="xpos"/></argument></block></argument><argument>15</argument></block></argument></block></argument></block></argument><argument>0.5</argument></block></argument><argument>2</argument></block></argument><argument>1</argument></block></argument></block></argument><argument>0.5</argument></block></argument><argument>4</argument></block></argument></block></argument></block></argument><argument><block selector="computeFunction:of:"><argument>atan</argument><argument><block selector="dividedBy"><argument><block selector="-"><argument><block selector="ypos"/></argument><argument><block selector="mouseY"/></argument></block></argument><argument><block selector="+"><argument><block selector="-"><argument><block selector="xpos"/></argument><argument><block selector="mouseX"/></argument></block></argument><argument>1.0e-14</argument></block></argument></block></argument></block></argument></block></scratchScript>

It is a MASSIVE binomial.
The second term is basically the above, with 0.0000000000001 added to the denominator to avoid division by zero.

The first is a LONG, but foolproof mathematical way of taking any number, and returning it's sign. I need this, as TAN cannot distinguish between positive and negative angles, as all slopes (the argument) are bidirectional. So I need to do that conversion myself, via this first term. I just came up with this now, but if anyone else has a simpler mathematical way of deducing the sign of a number, please tell me.


"I'd love to change the world, but they haven't released the source code yet."
Check out the latest version of Streak --> http://billy.scienceontheweb.net/Streak

Offline

 

#68 2010-06-23 11:59:06

shadow_7283
Scratcher
Registered: 2007-11-07
Posts: 1000+

Re: Trigonometry Help

billyedward wrote:

Ok, I fixed it.
Here is the XML code for the working block:

Code:

<?xml version="1.0" encoding="UTF-8" ?><scratchScript><block selector="-"><argument><block selector="+"><argument>-90</argument><argument><block selector="*"><argument>90</argument><argument><block selector="*"><argument><block selector="-"><argument><block selector="computeFunction:of:"><argument>abs</argument><argument><block selector="-"><argument><block selector="\\"><argument><block selector="+"><argument><block selector="rounded"><argument><block selector="computeFunction:of:"><argument>10 ^</argument><argument><block selector="+"><argument><block selector="-"><argument><block selector="mouseX"/></argument><argument><block selector="xpos"/></argument></block></argument><argument>15</argument></block></argument></block></argument></block></argument><argument>0.5</argument></block></argument><argument>2</argument></block></argument><argument>1</argument></block></argument></block></argument><argument>0.5</argument></block></argument><argument>4</argument></block></argument></block></argument></block></argument><argument><block selector="computeFunction:of:"><argument>atan</argument><argument><block selector="dividedBy"><argument><block selector="-"><argument><block selector="ypos"/></argument><argument><block selector="mouseY"/></argument></block></argument><argument><block selector="+"><argument><block selector="-"><argument><block selector="xpos"/></argument><argument><block selector="mouseX"/></argument></block></argument><argument>1.0e-14</argument></block></argument></block></argument></block></argument></block></scratchScript>

It is a MASSIVE binomial.
The second term is basically the above, with 0.0000000000001 added to the denominator to avoid division by zero.

The first is a LONG, but foolproof mathematical way of taking any number, and returning it's sign. I need this, as TAN cannot distinguish between positive and negative angles, as all slopes (the argument) are bidirectional. So I need to do that conversion myself, via this first term. I just came up with this now, but if anyone else has a simpler mathematical way of deducing the sign of a number, please tell me.

That's really cool but... I don't understand any of the XML.

Oh well.

I need help with something else.
What is the best way to draw a circle? I have tried to repeat a block 360 times (but it crowded the scripts to much and was a pain to edit). I tried using the atomic feature in BYOB (but even that didn't draw fast enough). And I tried yelling at it (but it didn't work).

Any ideas how I can draw a circle efficiently with a pen? Please note that it won't remain a circle. It's shape will be transformed.

Offline

 

#69 2010-06-23 15:38:49

markyparky56
Scratcher
Registered: 2008-03-20
Posts: 1000+

Re: Trigonometry Help

billyedward wrote:

Ok, I fixed it.
Here is the XML code for the working block:

Code:

<?xml version="1.0" encoding="UTF-8" ?><scratchScript><block selector="-"><argument><block selector="+"><argument>-90</argument><argument><block selector="*"><argument>90</argument><argument><block selector="*"><argument><block selector="-"><argument><block selector="computeFunction:of:"><argument>abs</argument><argument><block selector="-"><argument><block selector="\\"><argument><block selector="+"><argument><block selector="rounded"><argument><block selector="computeFunction:of:"><argument>10 ^</argument><argument><block selector="+"><argument><block selector="-"><argument><block selector="mouseX"/></argument><argument><block selector="xpos"/></argument></block></argument><argument>15</argument></block></argument></block></argument></block></argument><argument>0.5</argument></block></argument><argument>2</argument></block></argument><argument>1</argument></block></argument></block></argument><argument>0.5</argument></block></argument><argument>4</argument></block></argument></block></argument></block></argument><argument><block selector="computeFunction:of:"><argument>atan</argument><argument><block selector="dividedBy"><argument><block selector="-"><argument><block selector="ypos"/></argument><argument><block selector="mouseY"/></argument></block></argument><argument><block selector="+"><argument><block selector="-"><argument><block selector="xpos"/></argument><argument><block selector="mouseX"/></argument></block></argument><argument>1.0e-14</argument></block></argument></block></argument></block></argument></block></scratchScript>

It is a MASSIVE binomial.
The second term is basically the above, with 0.0000000000001 added to the denominator to avoid division by zero.

The first is a LONG, but foolproof mathematical way of taking any number, and returning it's sign. I need this, as TAN cannot distinguish between positive and negative angles, as all slopes (the argument) are bidirectional. So I need to do that conversion myself, via this first term. I just came up with this now, but if anyone else has a simpler mathematical way of deducing the sign of a number, please tell me.

Why XML? Scratch/squeak/smalltalk understands it?


http://j.mp/jgVnTq
Check out my game engine development site: NewDawn I'm a Level 171 Scratcher.I am http://bit.ly/nkvLNT

Offline

 

#70 2010-06-23 16:32:39

nXIII
Community Moderator
Registered: 2009-04-21
Posts: 1000+

Re: Trigonometry Help

billyedward wrote:

Ok, I fixed it.
Here is the XML code for the working block:

Code:

<?xml version="1.0" encoding="UTF-8" ?><scratchScript><block selector="-"><argument><block selector="+"><argument>-90</argument><argument><block selector="*"><argument>90</argument><argument><block selector="*"><argument><block selector="-"><argument><block selector="computeFunction:of:"><argument>abs</argument><argument><block selector="-"><argument><block selector="\\"><argument><block selector="+"><argument><block selector="rounded"><argument><block selector="computeFunction:of:"><argument>10 ^</argument><argument><block selector="+"><argument><block selector="-"><argument><block selector="mouseX"/></argument><argument><block selector="xpos"/></argument></block></argument><argument>15</argument></block></argument></block></argument></block></argument><argument>0.5</argument></block></argument><argument>2</argument></block></argument><argument>1</argument></block></argument></block></argument><argument>0.5</argument></block></argument><argument>4</argument></block></argument></block></argument></block></argument><argument><block selector="computeFunction:of:"><argument>atan</argument><argument><block selector="dividedBy"><argument><block selector="-"><argument><block selector="ypos"/></argument><argument><block selector="mouseY"/></argument></block></argument><argument><block selector="+"><argument><block selector="-"><argument><block selector="xpos"/></argument><argument><block selector="mouseX"/></argument></block></argument><argument>1.0e-14</argument></block></argument></block></argument></block></argument></block></scratchScript>

It is a MASSIVE binomial.
The second term is basically the above, with 0.0000000000001 added to the denominator to avoid division by zero.

The first is a LONG, but foolproof mathematical way of taking any number, and returning it's sign. I need this, as TAN cannot distinguish between positive and negative angles, as all slopes (the argument) are bidirectional. So I need to do that conversion myself, via this first term. I just came up with this now, but if anyone else has a simpler mathematical way of deducing the sign of a number, please tell me.

I don't really know what this looks like, but you should probably look at my five-ish-line approach. It's simple, but 100% effective (or is it affective? Ugh, I always remember these things, but now I forget!).

Last edited by nXIII (2010-06-23 16:33:03)


nXIII

Offline

 

#71 2010-06-23 16:43:03

shadow_7283
Scratcher
Registered: 2007-11-07
Posts: 1000+

Re: Trigonometry Help

shadow_7283 wrote:

I need help with something else.
What is the best way to draw a circle? I have tried to repeat a block 360 times (but it crowded the scripts to much and was a pain to edit). I tried using the atomic feature in BYOB (but even that didn't draw fast enough). And I tried yelling at it (but it didn't work).

Any ideas how I can draw a circle efficiently with a pen? Please note that it won't remain a circle. It's shape will be transformed.

Offline

 

#72 2010-06-23 17:57:49

nXIII
Community Moderator
Registered: 2009-04-21
Posts: 1000+

Re: Trigonometry Help

shadow_7283 wrote:

shadow_7283 wrote:

I need help with something else.
What is the best way to draw a circle? I have tried to repeat a block 360 times (but it crowded the scripts to much and was a pain to edit). I tried using the atomic feature in BYOB (but even that didn't draw fast enough). And I tried yelling at it (but it didn't work).

Any ideas how I can draw a circle efficiently with a pen? Please note that it won't remain a circle. It's shape will be transformed.

working on it, BYOB.


nXIII

Offline

 

#73 2010-06-24 10:55:22

bharvey
Scratcher
Registered: 2008-08-10
Posts: 1000+

Re: Trigonometry Help

shadow_7283 wrote:

What I'm trying to do now is calculate what degree of a circle the mouse is at.

If I'm understanding the question correctly, the circle itself is pretty much irrelevant.  What counts are the position of the center of the circle, and the position of the mouse.  You just put a sprite at the center of the circle and say POINT TOWARDS [MOUSE POINTER].

If you really want to draw a tangent from the mouse to the circle, then you have to do some geometry.  The crucial fact is that tangents to a circle are perpendicular to the radius through the point of intersection.  So draw three segments: (1) the tangent you're trying to find; (2) the radius perpendicular to that tangent; (3) the segment connecting the mouse to the center of the circle.  What you've drawn is a right triangle, so the angle between segments 1 and 3 is the arcsin of the ratio of #2/#3.  (You don't know the length of #1 yet so you can't use it in this calculation.)  So put a sprite at the mouse pointer, point it towards the center of the circle, then turn by that arcsin and you're pointing the right way.  As for the length of #1 you just use the Pythagorean theorem.

Of course there are two different tangents; you can turn left or turn right and either should work.


http://cs.berkeley.edu/~bh/sig5.png

Offline

 

#74 2010-06-24 11:05:29

bharvey
Scratcher
Registered: 2008-08-10
Posts: 1000+

Re: Trigonometry Help

shadow_7283 wrote:

What is the best way to draw a circle?

REPEAT 360 [MOVE 1 STEP TURN 1 DEGREE]

but that circle isn't centered on your current position, so you might have to move to its edge first.

The circumference of this circle is (approximately) 360, so its radius is 180/pi.  Adjust the step or the turn if you want a different size.

(Math lesson:  One way to define a circle, the way everyone knows, is that it's the locus of points a fixed distance from a center point.  But another way, provably equivalent, is that a circle is a curve of constant curvature -- it keeps turning by the same amount everywhere.  The program above is based on that understanding: for every little bit you move, you have to turn the same amount (same as the previous turn, I mean, not turn=move).  I think you get this in second semester calculus.  smile  )


http://cs.berkeley.edu/~bh/sig5.png

Offline

 

#75 2010-06-24 11:33:14

shadow_7283
Scratcher
Registered: 2007-11-07
Posts: 1000+

Re: Trigonometry Help

That would be great, normally. But this circle won't remain a circle. So I'm using cos and sin multiplied by the radius to give me my shape. Really I meant the MOST EFFICIENT way to draw a circle. Because I just can't do it fast enough.

Offline

 

Board footer