nXIII wrote:
shadow_7283 wrote:
nXIII is smarter than everybody.
![]()
![]()
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... )
Offline
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!
![]()
Fine then.
Offline
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
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?
Offline
Offline
cds56 wrote:
Subh wrote:
GREAT WORK NXIII
How old are you?I'm 15nXIII 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)
Offline
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:
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)
Offline
Billyedward is smarter than nXIII.
Offline
shadow_7283 wrote:
Billyedward is smarter than nXIII.
![]()
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?
pfft
Offline
I wasn't trying to be technical. It was a joke. Hence the
Offline
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?
Offline
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!
Last edited by MathWizz (2010-06-22 21:36:01)
Offline
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!
![]()
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.
Offline
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!
![]()
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.
Offline
Ok, I fixed it.
Here is the XML code for the working block:
<?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.
Offline
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
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?
Offline
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)
Offline
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
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.
Offline
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.
Offline
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.
)
Offline
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