Quote:
Originally Posted by Greyscale
Works out the speed based on mass and distance from each other? What speed?
|
Sorry, I should have provided context. Space.
Typically all objects have a continuous although very very very slight gravitation pull at a distance (apparently far away black holes have the same impact as the 'beating of a gnat's wings', if I recall correctly) which increases as the objects get closer.
My function was a lot simpler; drawing two objects together based on mass. One student had told me writing such a function was impossible (I doubted that given gravity exists and that's technically a 'mathematical function'). I missed out on physics and mathematics largely (which is a pity - I enjoyed both), but I figured speed = (mass1 + mass2)/distance (if I recall correctly) and started working on momentum and potential momentum (as all objects would gain so much speed they would overshoot on every pass). I noticed gravitation pull had 'rings' and as you pass each one, the speed would exponentially increase. Although my theories and that of other people rarely coincide.
I throw this up here as inter-related gravitation pull of various interstellar objects would be incredibly useful, whether as studying for physics generally or a more specific space-based game (I had ideas for the latter but various things meant I abandoned the project).
I'd say stick to the 2D axis, as 3D axis can be expanded from the 2D axis (if we start 3D we would have too many variables to keep track of).
Quote:
Originally Posted by PM
Haha, I would still just love to know what need there is to abuse that logic if the OR operator does exactly what you want without abusing any logic -- or is it just to be more obscure?
|
I suppose to be more obscure. An OR operator could work in it's place, but I find adding booleans makes the code look more interesting. Plus, I wouldn't have learnt anything if I hadn't.
Bitwise physics abuse. The problem with me doing anything physics as I previously mentioned is I missed out on both physics and mathematics. I can quickly grasp and create new theories rapidly, so the physics isn't such a biggie; it's the mathematics. I might have an idea that could calculate the universe, but without knowing mathematical functions I wouldn't be able to write it (or would get bogged down re-writing mathematical functions).
Even my barrel launcher based on client eye angles uses my own written calculus to work out the directional velocity because I don't know anything about functions that convert angles to co-ordinates...
PHP Code:
GetClientEyeAngles(client,ang);
answer = ang[1];
if(RoundToFloor(answer) > -181 && RoundToFloor(answer) < 0)
{
answer = float(RoundToFloor(answer) * -1)
}
if(RoundToFloor(answer) < 91 && RoundToFloor(answer) > -1)
{
answer = float(90 - RoundToFloor(answer));
vel[0] = float(40 * RoundToFloor(answer));
}
if(RoundToFloor(answer) > 90 && RoundToFloor(answer) < 181)
{
answer = float(RoundToFloor(answer) - 90);
vel[0] = float(-40 * RoundToFloor(answer));
}
answer = ang[1];
if(RoundToFloor(answer) < -91 && RoundToFloor(answer) > -181)
{
answer = float(-180-RoundToFloor(answer));
}
if(RoundToFloor(answer) > 90 && RoundToFloor(answer) < 181)
{
answer = float(180-RoundToFloor(answer));
}
if(RoundToFloor(answer) > -91 && RoundToFloor(answer) < 91)
{
vel[1] = float(40 * RoundToFloor(answer));
}
vel[2] = float(-40 * RoundToFloor(ang[0]));
It's not like it's non-functional (quite the opposite, it's quite precise), just it's a wasted effort figuring out formulae for something that's already done. I just can't learn mathematics because it truly is written like absolute gibberish. It's the only subject area who's language I know makes up symbols or steals other symbols whether they want to represent whatever they can't be arsed to explain because it's too damn complex.
Quote:
Originally Posted by Theme97
However, I could really use something similar to this (given object A, point B, and X frames, move A to B but only decelerate; 2D) for another plugin of mine, so it would be nice to know what algorithm to use.
|
You don't need to know physics or mathematics to get what you want, but it helps.
Simply put, you get the two co-ordinates, using py's theorem (Which is two X co-ords added together times by themselves, the two Y co-ords added together times by themselves, add the two answers, square root the answer), calculate the distance between the two, divide that distance by the speed so you get the frame spacing (these are sometimes called 'steps').
This is the part I can't tell you how to do (although there are mathematical functions for this), calculate the angle between the two points and the horizontal line, then convert the angle into co-ordinates by combining (again with a mathematical function) angle with the frame spacing/steps, and keep running those steps until you change the speed, when you'll need to recalculate the steps.
Change speed over time by storing the time it starts, seeing the elapsed time since starting, whether or not it exceeds X, increasing it and resetting it if it has.
Edit: Thats wrong. That's acceleration. Deceleration would be division. To change speed just modify the speed and recalculate the steps.
In short?
Speed = Speed + (X.Units * Time.Units)
Distance = ((X+X2)* + (Y+Y2)*)(SquareRoot the answer)
Steps = Distance/Speed
Current X,Y = Steps+Angles (Not literally add - you need to combine to two using RadToSine or whatever).
Done. But this is what I mean about my lack of mathematical knowledge.