Use an axis and an angle, then check whether the proposed orientation dot axis is within the angle, it's a cone check, if both axes are normalised the dot product will be > cos(angle) if it is within the cone
EDIT: > not <
Posted by Paradigm Shifter on 18 July 2015 - 02:12 AM
Use an axis and an angle, then check whether the proposed orientation dot axis is within the angle, it's a cone check, if both axes are normalised the dot product will be > cos(angle) if it is within the cone
EDIT: > not <
Posted by Paradigm Shifter on 17 October 2014 - 04:53 PM
Posted by Paradigm Shifter on 16 October 2014 - 07:01 AM
The interval of convergence is too small.
Are you using floating point or fixed point, I don't understand what you mean by this: of floating range from 24 bit to like 16 bit.
Using 1/x is going to be a lot more accurate than a (poor) approximation which is what the Taylor Series expansion about 1 will give you. Some functions aren't approximated very well at all by Taylor Series (of which McLaurin series is just a special case), e.g. sqrt(x).
Or you could use the Laurent Series, f(x) = x^{-1}
Posted by Paradigm Shifter on 16 October 2014 - 06:37 AM
That's not defined at x = 0 ;)
You'll have to use the Taylor series approximation around a suitable point (probably x = 1).
What's wrong with just using 1/x? It's going to be a lot more efficient than calculating a power series expansion...
EDIT: It also has a very narrow radius of convergence ( abs(1-x) < 1 when centred on 1). So it's pretty much useless... See http://www.wolframalpha.com/input/?i=taylor+series+1%2Fx+a%3D1&lk=4
Posted by Paradigm Shifter on 10 October 2014 - 01:44 PM
Posted by Paradigm Shifter on 10 October 2014 - 01:39 PM
Posted by Paradigm Shifter on 07 October 2014 - 01:34 PM
I saw this about a year ago in a graphics engine, and I've kept a screenshot to remind me of it:
float PI = 57.29578f; // (7/22)*180I love this on two levels. First, this number isn't the universal constant pi. That should be enough, but... the number isn't the result of the calculation in the comment, either.
7/22 is approximately pi. The number be assigned here is actually pi/180, and it was used in the code to convert radians to degrees.
Posted by Paradigm Shifter on 07 October 2014 - 08:17 AM
I thought that (in the real world), non-guided bombs fall straight down.
Nope, they start off with the velocity the craft had when the bomb was released, then that initial velocity is influenced by gravity (and drag if you factor that in). Otherwise, dropping a cup whilst inside an aeroplane would mean it would shoot to the back of the plane with remarkable speed ;)
Posted by Paradigm Shifter on 07 October 2014 - 01:58 AM
The easy (cheating) way is to make the bezier curve centred on the player, If they aren't moving too fast that looks ok.
Othwerwise you have to update the control points as the boomerang is in flight, again you can centre it on the player but keep updating the control points as the player moves, with the final point always on the player.
You could also make the boomerang miss and wait until it is picked up again/destroyed before letting the player use it again, I think 2d zelda did this, not sure. However that was just a back and forward along a straight line boomerang not on a bezier.
Posted by Paradigm Shifter on 26 August 2014 - 05:45 AM
You need to use 52 instead of 51 (since x % 51 gives a number from 0 to 50, not 0 to 51).
You also want to use (h - j) / 52 since division has higher precedence than subtraction.
You probably don't need all combinations either the only thing you care about is card value and whether they are the same suit or off suit.
EDIT: And what Bacterius said.
Posted by Paradigm Shifter on 21 August 2014 - 03:03 AM
You need to add std:: before each use of cout, cin and endl.
Otherwise add
using namespace std;
after the #includes.
Your book must be rather old...
EDIT: Oh you have that already... didn't see that.
As L. Spiro says, you need to do a full rebuild.
EDIT2: You keep editing the code, making my replies seem foolish.
EDIT3: Nope, my mistake, there are 2 programs not just 1, one of them has using namespace std in each function and the other has using namespace std.
I'll get my coat ;)
Posted by Paradigm Shifter on 14 August 2014 - 05:57 AM
It's the same equation,
p = a + (b-a) * t
where a and b are the endpoints of the line and t ranges from 0 to 1 (unless you want the infinite line through the points, where t can be any real number).
Just set a = (2, 0, -1) and b = (3, 4, 5) and you are good to go... isn't that what you did in the 2d case?
Posted by Paradigm Shifter on 14 August 2014 - 05:25 AM
Do it in the way that is easiest for you, the reader of the code, to understand.
Although a good idea would be to have +1 for O and -1 for X instead of 1 and 2, in that way you can sum up all 3 rows (in a loop), all 3 columns (in a loop) and both diagonals and if they sum to +3 O has a winning line, -3 means X has a winning line. You can exit the test early if you find a win for either player.
More sophisticated would be to use a bitboard but Alvaro will probably be along in a minute to boggle your mind with that idea ;)
Posted by Paradigm Shifter on 26 July 2014 - 03:58 PM
Posted by Paradigm Shifter on 26 July 2014 - 02:34 PM
GameDev.net™, the GameDev.net logo, and GDNet™ are trademarks of GameDev.net, LLC