# Koga73

Member

17

125 Neutral

• Rank
Member
1. ## translate point set distance towards quaternion

Yeah as for rotating zero in my example I know it doesn't do anything it was just easy math for me to show what I expect the resulting point to be. As you stated above applying the rotation to (distance, 0, 0) does work! [code] var quat:Quaternion = new Quaternion(); quat.fromAxisAngle(new Vector3D(0, 1, 0), rot * MathConsts.DEGREES_TO_RADIANS); var mat:Matrix3D = new Matrix3D(); mat.position = new Vector3D(10, 0, 0); mat.append(quat.toMatrix3D()); plane.position = mat.position; [/code] This is good and all but now I want to abstract it out into a function that takes in an axis vector, an angle, and a distance. It doesn't seem like the same code above would work if the axis were not the Y due to the position being hard-coded to (distance, 0, 0). I guess at this point I'm just looking for what that vector should be? The magnitude should always be the distance but does it matter what value I start it at?
2. ## translate point set distance towards quaternion

In my case I have an XZ plane with the normal facing +Y. I am using the following for my quaternion: var quat:Quaternion = new Quaternion(); quat.fromAxisAngle(new Vector3D(0, 1, 0), rot * MathConsts.DEGREES_TO_RADIANS); var mat:Matrix3D = quat.toMatrix3D(); So now I have a rotation matrix... I am wanting to make the plane orbit around the origin... so for instance if my distance is 10 units and my origin is (0, 0, 0) and my angle is 0° then I would expect the plane's resulting position to be (10, 0, 0). I'm just not sure how to actually apply the distance and quaternion to get the planes resulting position?
3. ## translate point set distance towards quaternion

Hi, I'm new to quaternions and want to use the resulting rotation matrix to translate a point a towards the quaternion given a set distance. Without using quaternions or matrices I would do something like this: public static function calcVector(angle:Number, distance:Number = 1):Vector2D { var vec:Vector2D = new Vector2D(); vec.x = Math.sin(90 - angle) * distance; vec.y = Math.sin(angle) * distance; return vec; } How do I mimic this functionality using the quaternions resulting rotation matrix as my "angle" parameter? Assuming the starting point is at (0, 0, 0) and I have a rotation matrix from a quaternion how do I translate the starting point towards the quaternion with a set distance of say 10 units? I would like to keep everything in the form of vectors, quaternions, and matrices. Thanks for the help!
4. ## OpenGL UV Mapping fundamentals

Thanks for the reply. I get that part.. the part I don't understand is how it projects the texture on a surface with perspective.
5. ## OpenGL UV Mapping fundamentals

Hi, I want to know the math behind how a texture is mapped to a plane using UV coordinates... I've looked online quite a bit but can't seem to find anything about the actual math and logic of how this is done outside of a graphics engine such as OpenGL. Thanks
6. ## sync issues

Hey, The game I'm working on is a real-time multiplayer flash game. It uses smart fox server to allow clients to communicate. The game does not run on the server, but rather on the clients and the server just serves as a form of communication between the players. This works for the most part, however I am having sync issues and need to get them worked out. I want to redo the sync system and here is what I am thinking: -One player "hosts" game. -Player logs in their game timers sync up -Whenever a keystroke or action is performed that action is sent through the host to all other players -When an event is received by another player it is placed into a queue -When the game time on the local machine hits the time stamp specified on the event in the queue the event fires -After the event fires the game timer stops and does not start back up until another event is received Will I have any problems with this? I figured I'd stop the game timer between events because otherwise if an event is received and the local game timer is already past the time stamp, what would I do? And also, concerning overclocked machines... their game timer will be running faster than normal. How will this effect syncing? Thanks
7. ## calc velocity on inclined plane with friction

Alright so I've really been struggling with getting the friction working over the past couple days. The problem I'm having is that the acceleration is half the max speed, so it will take half a second to reach max speed. That all works in a frictionless world... but as soon as I apply friction the friction value almost cancels out the acceleration so it takes FOREVER to reach max speed from a stationary position. On the same note, if I turn down the friction value then the player accelerates fine, but then slides and doesn't stop. I am having the hardest time finding a good mid-ground. Or perhaps I need a different approach. My Friction Function (actionscript 3): public static function applyFriction(toPawn:Pawn, overTime:Number):void { if (!toPawn._onPhysical){ return; } if (toPawn._speed._MPS._x == 0){ return; } var tSpeedModifierX:int = toPawn._speed._MPS._x / Math.abs(toPawn._speed._MPS._x); var tFrictionCoefficient:Number = toPawn._friction * toPawn._physicalBelow._friction; var tFriction:Number = -(15) * tFrictionCoefficient; var tDeceleration:Vector2D = new Vector2D((tFriction * tSpeedModifierX), 0); applyAcceleration(toPawn, overTime, tDeceleration); if ((toPawn._speed._MPS._x / Math.abs(toPawn._speed._MPS._x)) != tSpeedModifierX){ toPawn._speed._MPS._x = 0; //Check to see if we have gone past 0 } toPawn._speed.calcMPS(); }
8. ## calc velocity on inclined plane with friction

So I got most of it working. The thing that I am not seeing with your example is mass. The deceleration due to friction should take into consideration the mass of the object. As in the real world it will take much longer for a semi truck to stop than a car. Any suggestions to how mass can be worked in to work with friction?
9. ## calc velocity on inclined plane with friction

wow great stuff! I think this is exactally what I was looking for. They don't teach it like that in physics lol. I really appriciate all the help! I'm gonna work on implementing some of it tomorrow I'll let you know how it goes.
10. ## calc velocity on inclined plane with friction

Hmm... the project is an actionscript project so I have written the engine myself. So far everything works with the exception of friction. I wrote a class called Vector2D that stores the x and y components of a vector and has math operations in it. So far with all of the math I am doing I am mostly working with the x and y components of the vector independtly. This is really the first physics engine I have written. It is for a college project. Quote:You should not be concerned with theta, cosine, or independent components. (ie x, y, z) You should treat everything as vectors and use vector operations such as dot product and cross product. How can I apply cross/dot product to the problem at hand? Quote:You'd also need to integrate the force from gravity projected onto the normal. How do I project the force of gravity (9.81 m/s) to the normal of the surface since gravity acts in the y direction? Quote:If you apply friction after the acceleration of gravity, it should be able to diminish any gravity acceleration rate less than the friction rate, bringing the object to a stop. Gravity has already been calculated into the speed of the player before the friction function will be called. To keep it simple for now, lets say the friction coefficient is .8. How could the amount of friction ever be greater than the amount of gravity? Am I comparing mg*frictionCoefficient to mg? Like I've said so far I have been working with x/y components of my vectors. Is there a better solution? After re-examining the problem from a physics stand point I have realized that what I actually need to solve for is the new acceleration of the object, and then the acceleration values should slow the object down over time (unless the above ideas will work better)? Thanks for all your help
11. ## calc velocity on inclined plane with friction

Thanks for the suggestion but I'm not quite sure that is what I am looking for. I am looking for something more along the lines of a formula. Such as (keep in mind I am making this up) Vfx = Vix + (mg)(cos(theta)) * (frictionCoefficient) Or something similar to that so I can calculate the new speed of the player based on the initial speed of the player and factor in the slope of the incline and the friction coefficient.
12. ## calc velocity on inclined plane with friction

Quote:what's the coefficient of restitution? There isn't a coefficient of restitution. Only friction coefficient between the object and the surface Quote:can the object roll down the hill? no Quote:Why do you assume the object will continue to slide down the hill and not come to a stop? I do think that it will come to a stop. I'm hoping that when the object is on the slope it will already have an initial velocity vector. So I want to calculate the final velocity vector using the initial velocity when it hits the slope along with the friction coeffecient I have between the two objects, and of course theta. Quote:how accurate of a friction model are you interested in? Not super accurate. The physics engine itself is pretty basic. The objects all have acceleration and velocity vectors. Basic Bounding Box / Proximity collision models. I have the players working in game but they slide forever because there is no friction to stop them. I want to apply friction to my players on all surfaces, which could include slopes (defined by two x/y positions). Quote:Are you familiar with vectors? is this a 2d side scroller or a 3d game? 2d side scroller
13. ## calc velocity on inclined plane with friction

Hey, so in a 2d physics engine I have an inclined plane with a frictional value. Along with a "player" that has a mass. The player object will have an initial x and y velocity and hit an inclined plane that has a slope (theta) along with a friction coefficient. 1. How do I calculate the new speed using the initial speed, mass, gravity, friction coefficient of slope, and angle of slope for both the x and y directions over a period of time (delta). (This must work even if the slope is 0°) 2. How does acceleration factor in? You must accelerate down the slope, how is this calculated. Any help is appreciated! Thanks
14. ## Reference To Pointer help

Ok, using the * instead of & I get no more compile errors, only linking errors: 1>------ Build started: Project: Block_Out, Configuration: Debug Win32 ------ 1>Compiling... 1>Tile.cpp 1>TileMap.cpp 1>Generating Code... 1>Linking... 1>Block_Out.obj : error LNK2001: unresolved external symbol "public: static class Texture * * Texture::_textures" (?_textures@Texture@@2PAPAV1@A) 1>TileMap.obj : error LNK2001: unresolved external symbol "public: static class Texture * * Texture::_textures" (?_textures@Texture@@2PAPAV1@A) 1>E:\C++ Projects\Block_Out\Debug\Block_Out.exe : fatal error LNK1120: 1 unresolved externals 1>Build log was saved at "file://e:\C++ Projects\Block_Out\Debug\BuildLog.htm" 1>Block_Out - 3 error(s), 0 warning(s) ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ========== And Its happening here, I dont know why though: void TileMap::setTileMap(){ for (unsigned int i = 0; i < MAP_SQUARE; i++){ for (unsigned int j = 0; j < MAP_SQUARE; j++){ _tiles[(i * MAP_SQUARE) + j] = new Tile(i * Tile::WIDTH, j * Tile::HEIGHT, Texture::_textures[0]); } } }
15. ## Reference To Pointer help

error C2664: 'Tile::Tile(float,float,Texture &)' : cannot convert parameter 3 from 'Texture *' to 'Texture &'