Posts: 6,236
Threads: 310
Joined: Jan 2011
Reputation:
0
I don't want a sphere - I want a cylinder.
Posts: 4,885
Threads: 57
Joined: Jun 2012
Reputation:
0
It's the same thing (sorta)
"Consider the beam just a line with it's radius determined relative to the radius of a sphere in which the line will intersect."
I think your getting the visualization wrong, you don't need a cylinder you need a line, the sphere makes the line cylindrical. The sphere is your TARGET point when that is moved around it would form a cylindrical collision if you plotted it enough times.
Posts: 791
Threads: 65
Joined: Oct 2009
Reputation:
0
good luck, i think you'll need it
Hoping someone will answer.. lol
Posts: 1,046
Threads: 29
Joined: Mar 2010
Let's say your beam has a x, y, and z lenght (also called vector), and since vectors are freely movable, you need to define your current position, by creating a linear function made of vectors.
(my x, my y, my z) + s * (lenght x, lenght y, lenght z)
Now this function tells you that you have a three dimensional finite line, fixed at some position in a coordinates system, and it is stretchable. Making s infinite makes the whole line infinite long, anyway.
Try to handle some object as a sphere, and since a sphere has a center point and on every side the same radius, you can determine the closest approach of your "beam" to the single point (center of the sphere).
Now we have to allocate, where the vector from the center of the sphere points meets our beam function and what direction it has to go to meet actually our beam function.
We can create a line from our position to the center of the sphere (object) and define it as a vector and use the first vector we know from our beam function, we can create a normalized vector using 2 vectors in a three dimensional space (vector cross product). Now we create a normalized vector using our generated normalized vector and the vector known from our beam function.
Great, this vector now can be transformed into a line function, giving it the start position at the center of the sphere and creating an equation to detect how long your line from the center of the sphere to our beam function has to be, to cross it. The now known variable "s" can be used to calculate the vector, using only the line function from the center of the sphere to the cross point of our beam function, throwing away the starting position values and have a proper vector, which describes how long it is and what direction it goes. We can simply calculate its real lenght using Pythagora's equation sqrt(aІ + bІ + cІ) = d and you will get the actual closest distance from the center of the sphere to the closest approach. If your result equals or is smaller than your sphere radius size, your beam crosses your sphere (hit) else it does not (no hit).
Edit: There is a much faster way to compare sizes without using square root at all,
ResultІ should equal or be smaller than radiusІ to detect it as a hit.
resultІ <= radiusІ
instead
sqrt(resultІ) <= radius
Posts: 2,938
Threads: 162
Joined: May 2010
Quote:
Originally Posted by [uL]Pottus
It's the same thing (sorta)
"Consider the beam just a line with it's radius determined relative to the radius of a sphere in which the line will intersect."
I think your getting the visualization wrong, you don't need a cylinder you need a line, the sphere makes the line cylindrical. The sphere is your TARGET point when that is moved around it would form a cylindrical collision if you plotted it enough times.
|
Listen to what they say about spheres, remember they might not explain the looping part, but you need to loop.
MP2 he is right, let me show you what he means... (instead of trying to think about your street or class logic, listen to the real facts)
MP2 for us to make this right for you, you need to have a base code we can work on, show us what you want to do with the code.
Posts: 104
Threads: 4
Joined: Oct 2012
Reputation:
0
Use a sphere as the player's position.
That equation checks to see if the cylinder (path of the rocket) goes through a sphere (the player's position).