This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
Messages - 3rik
Pages: 1 2 3 [4] 5 6 ... 8
46
« on: January 29, 2012, 04:46:52 pm »
48
« on: January 17, 2012, 10:57:30 pm »
I found the 2D parametric equations for the trajectories of objects where k is the drag coefficent, V 0 is the initial velocity, g is the acceleration due to gravity, θ is the angle above the ground and x 0 and y 0 are the starting coordinates. To add the third dimension I know I just need to do a simple rotation but I still need to figure out the backspin part. This is a legal double post.
49
« on: January 16, 2012, 12:10:48 pm »
While we believe that online piracy by foreign websites is a serious problem that requires a serious legislative response, we will not support legislation that reduces freedom of expression, increases cybersecurity risk, or undermines the dynamic, innovative global Internet. It sounds hopeful that someone will do something to stop these bills and focus on the sites actually causing problems.
50
« on: January 16, 2012, 10:20:05 am »
This kind of makes sense. I have a few questions. What does S stand for? Do these factor in air resistance? (I forgot to be specific in my post) And what if I want φ to be the variable instead of x and y? EDIT 1: Since the Magnus force is perpendicular to the direction the ball is traveling, wouldn't it affect the x and y coordinates too? EDIT 2: I was looking at this but I have no idea of how to put all this information together. http://rockstarscience.net/baseball/HowToHitHomeRuns.pdf (ignore the bat stuff)
51
« on: January 15, 2012, 09:51:23 pm »
I'm working on a problem that involves accurately predicting the trajectory of a ball.
To simplify things a bit let's say I have a cannon that is capable of putting backspin on the cannonball. This cannon is capable of moving anywhere on the ground. It can adjust the angle it is firing at and how fast it shoots the cannonball. How do I determine what position, angle, and speed I need to hit a target in 3D space?
While looking on the internet I found a bunch of things that involved differential equations, the Magnus Effect, and integrals.
I haven't taken high school physics yet and I am only learning beginning to learn about definite integrals in calc 1.
If there's anyone that can explain a method for finding this that doesn't involve too much advanced calculus, they would be really helpful. It may eventually be included in a program so the less symbolic stuff the better.
Thanks in advance.
52
« on: January 14, 2012, 05:28:57 pm »
Is there any advantage with using on.create?
This is what the Nspire Scripting Application Programming Interface document says. 15.13 create on.create() This routine is called when the script application is created. The window size and graphics context are valid at this point. Use this routine to initialize graphical objects based on the window size. Don’t actually paint the screen in this routine since the on.paint event handler will be called soon after this routine finishes.
If you are making an app that depends on the screen size you can then use platform.window:height() or platform.window:width() to do calculations. I suppose you could call it later in the program again. I was just testing to see if I had any issues with it.
53
« on: January 14, 2012, 05:11:05 pm »
@adriweb I thought table.getn was removed after Lua 5.0 and replaced with the # operator.
@epic7 It depends on how Lua was set up on the system. I don't know the details because that gets into complicated C stuff. I can take a look at your code to see if I can spot an optimization.
54
« on: January 13, 2012, 11:51:11 pm »
And also, is there an easy way to add something to the end of the table and count the number of things in a table?
There are a few ways of determining the length of a table. The most obvious way is using the operator #. It basically starts at 1 and keeps adding 1 until it reaches a nil value. If there are any holes in your table this will give a smaller value. Another way to get a length is to use table.maxn(). It returns the key with the highest value. In my previous example #example == 1 but table.maxn(example) == 1337. This can also handle decimal numbers in the keys. One way to count all the elements in a table would be to use a function like this: function length(example) local index = 0 for _, __ in pairs(example) index = index + 1 end return index end
This will count every element in the table (except nil values, of course). I'll bet this way will be quite slow as the number of elements increases. If you wanted to add signal to show the end you could do something like this: stuffs = {1, 3, 5, 3, nil, "end"}
function length2(example) local index = 1 while example[index] ~= "end" do index = index + 1 end return index - 1 end
length2(stuffs) would return 5. However, in order to place the "end" into the table, you would have had to know where to put it and if you add or take away any elements you would have to adjust where "end" goes.
55
« on: January 13, 2012, 11:04:01 pm »
@someone I'd agree that that code looks neater. I was just being lazy and I only made the minimum amount of changes from epic7's code.
@ epic7 and cyanophycean314 I see that you're testing the program in oclua. By the time you paste the code in the program, the event on.create() has already been called so coord was never initialized.
56
« on: January 13, 2012, 12:33:03 am »
Welcome systwo to Omnimaga! Here are some extra peanuts in case they don't give you any on your next trip. jwalker, you can give peanuts by typing !peanuts
57
« on: January 13, 2012, 12:11:20 am »
Looked through the code a bit more and edited a couple things
function on.create() coord = {} for a=1, 14 do for b=1, 3 do if a~=7 and a~=14 then coord[a*9+b*3-11]=a --Changed all the 3s in front of the as to 9s also changed the 5, 4, and 3 to 11, 10, and 9 so that it would still start at coord[1] coord[a*9+b*3-10]=math.random(0,16) coord[a*9+b*3-9]=math.random(0,14) else coord[a*9+b*3-11]=a end end end end
function on.paint(gc) for a=1, 42 do if coord[a*3-2]~=7 and coord[a*3-2]~=14 then if coord[a*3-2]>7 then gc:fillArc((coord[a*3-2]-7)*38+coord[a*3-1],coord[a*3]+49,10,10,0,360) --subtracted 7 from coord[a*3-2] to line up the pieces else gc:fillArc(coord[a*3-2]*38+coord[a*3-1],coord[a*3]+141,10,10,0,360) end end end end
Using this code, I got the screenshot below. I made a couple extra tweaks to the numbers so that the pieces would line up.
As for adding things to tables, as long as the table has been initialized with a table constructor, any valid key can be paired with any valid value.
example = {} example[1] = 1 example[1337] = 3.141592 example["The Game"] = on.paint example[on.create] = "Never Gonna Give You Up" example[true] = false example.Omnimaga = {1, 2, 3, 4} --Same as example["Omnimaga"] = {1, 2, 3, 4}
Be wary though, #example ~= 1337 until example[2] through example[1336] have non-nil values
58
« on: January 11, 2012, 10:27:25 pm »
I noticed that some values in the coord table are being overwritten. Like when a=1 and b=2 coord[4]==1 but when a=2 and b=1 coord[4]==2. I'm running out of ideas for what is causing this error without seeing more code. Local variables are variables that are initialized with the word local in front of them. They only last until the end of the block they are created in. They can share the name of global variables. A description of this can be found here: http://www.lua.org/pil/4.2.html
59
« on: January 11, 2012, 09:56:43 pm »
Are there any local coord variables?
60
« on: January 11, 2012, 09:50:54 pm »
I come bearing the gift of peanuts! I hope you enjoy your time at Omnimaga.
Pages: 1 2 3 [4] 5 6 ... 8
|