2D Vector bullshit
1
Name:
Anonymous
2008-11-14 6:04
I've got 2 points (ie. X,Y vectors), and I need to find out the angle (degrees°) between them, so I can move an object which is at one of the points towards the other point.
How do I calculate the degrees plz???
2
Name:
Anonymous
2008-11-14 6:10
lrn2math
3
Name:
Anonymous
2008-11-14 6:15
Degrees suck balls anyway, everyone uses radians.
4
Name:
Anonymous
2008-11-14 6:23
HINT: Angular coefficients are given by the quotient y/x, where x is the horizontal coordinate and y is the vertical one.
Next step to you, anon.
5
Name:
Anonymous
2008-11-14 6:54
theta = |arctan(x0 ) - arctan(x1 )|
6
Name:
Anonymous
2008-11-14 7:14
USE THE POWER OF MIGHTY SINE
7
Name:
Anonymous
2008-11-14 7:31
There is no angle "between" two arbitrary points. There can always be a straight line segment connecting them.
8
Name:
Anonymous
2008-11-14 7:33
>>7
I've got 2 points (ie. X,Y vectors)
You are as dumb as OP, congratulations
9
Name:
Anonymous
2008-11-14 7:36
10
Name:
Anonymous
2008-11-14 7:45
USE THE FUCKING DOT PRODUCT
11
Name:
Anonymous
2008-11-14 10:31
USE THE FUCKING CROSS PRODUCT
12
Name:
Anonymous
2008-11-14 10:36
USE THE FUCKING PROJECTION
13
Name:
Anonymous
2008-11-14 10:36
USE THE FUCKING MATRIX MULTIPLY
14
Name:
Anonymous
2008-11-14 10:38
USE THE FUCKING DETERMINANT
15
Name:
Anonymous
2008-11-14 10:39
USE THE FUCKING EIGENVALUES
16
Name:
Anonymous
2008-11-14 10:39
USE THE FUCKING TRANSPOSE
17
Name:
Anonymous
2008-11-14 10:40
USE THE FUCKING ROW REDUCTION
18
Name:
Anonymous
2008-11-14 10:51
USE THE FUCKING TENSOR PRODUCT
19
Name:
Anonymous
2008-11-14 11:09
USE THE FUCKING DIRECTION COSINES
20
Name:
Anonymous
2008-11-14 11:11
USE THE FUCKING addition
21
Name:
Anonymous
2008-11-14 11:19
USE THE FUCKING QUATERNION NORM
22
Name:
Anonymous
2008-11-14 13:30
USE THE FUCKING FORCE LUkE
23
Name:
Anonymous
2008-11-14 14:59
USE THE FUCKING QUADRATIC FORMULA
24
Name:
Anonymous
2008-11-14 16:20
the proper way to do it isa*b=|a||b|cos(YOURFUCKINGANGLEHERE) to move away from vector a in every direction till it equals b
25
Name:
Anonymous
2008-11-14 19:07
USE THE FUCKING FORCED INDENTATION
26
Name:
Anonymous
2008-11-14 19:18
USE THE FUCKING
27
Name:
Anonymous
2008-11-14 20:07
FUCK THE USING
28
Name:
Anonymous
2008-11-14 22:29
THE USING, FUCK
29
Name:
Anonymous
2008-11-14 23:47
STOP USING DRUGS
30
Name:
Anonymous
2008-11-14 23:54
USE THE FUCKING POLAR COORDINATES
31
Name:
Anonymous
2008-11-15 2:01
USE THE FUCKING LAGRANGE POLYNOMINALS
32
Name:
Anonymous
2008-11-15 3:34
USE THE FUCKING HAMILTONIAN
33
Name:
Anonymous
2008-11-15 7:05
USE THE FUCKING GNIKCUF ETH ESU
34
Name:
HMA MEME FAN
2008-11-15 7:27
HAX MY FUCKING ANUS
35
Name:
Anonymous
2008-11-15 8:36
READ THE FUCKING SICP
36
Name:
Anonymous
2008-11-15 8:40
'hax my anus' has never been a meme.
37
Name:
noobular
2008-11-15 11:57
>>7
fuck. ok so this is some of my codez:
void Object_t::Move()
{
Accel.x = thrust * cos(DEG2RAD(headingDegs));
Accel.y = thrust * sin(DEG2RAD(headingDegs));
Vector += Velocity;
}
This will move the object's position (ie. Object_t.Vector) towards another 2D Vector, and the direction is based on
headingDegs . If headingDegs=0 it will go straight right, if headingDegs=90 it goes 90° from that point (ie. straight down) etc.
I just need to figure out what headingDegs should be based on my current location (Vector) and my target vector.
38
Name:
Anonymous
2008-11-15 12:21
39
Name:
Anonymous
2008-11-15 14:00
40
Name:
Anonymous
2008-11-15 14:03
41
Name:
Anonymous
2008-11-15 15:35
void Object_t::Move()
{
Accel.x = thrust * cos(DEG2RAD(headingDegs)); ?? OMG SO FUCKING OPTIMZIED!!!!!!!!!
Accel.y = thrust * sin(DEG2RAD(headingDegs));
Vector += Velocity;
}
42
Name:
Anonymous
2008-11-15 16:17
>>41
I KNOW RIGHT
I also forgot the
Velocity += Accel; line but eh, I only pasted what's necessary.
So how the piss do I calculate the headingDegs?
43
Name:
Anonymous
2008-11-15 19:13
44
Name:
Anonymous
2008-11-15 19:35
>>42
Here's what you do. Fuck that pansy ass cosine shit.
cos(x) = dot(X, Y)/(length(X)*length(Y))
x = arccos(dot(X, Y)/(length(X)*length(Y)))
There is the angle between the points. Blam. Read SICP.
45
Name:
Anonymous
2008-11-15 19:37
BTW if you dont know what dot and length are:
dot(X, Y) = X[1]*Y[1] + X[2]*Y[2]
length(X) = sqrt(X[1]*X[1] + X[2]*X[2])
Good day.
46
Name:
Anonymous
2008-11-16 9:14
OP here, finally got this shit working, thx guize l00l
47
Name:
noobular
2008-11-17 8:02
WAIT NO
It doesn't work when the target vector is to the left of my current position vector.
/** Move ()
*
* Move the object towards its vector.
*
*/
void Object_t::Move()
{
Velocity.x = thrust * cos(headingDegs);
Velocity.y = thrust * sin(headingDegs);
Vector += Velocity;
}
/** GetDegrees ()
*
* Set headingDegs based on Target vector.
*
*/
void Object_t::GetDegrees()
{
float dx, dy;
if (Target.y > Vector.y)
dy = Target.y - Vector.y;
else
dy = Vector.y - Target.y;
if (Target.x > Vector.x)
dx = Target.x - Vector.x;
else
dx = Vector.x - Target.x;
headingDegs = atan(dy / dx);
}
If I add this part to the end:
if (Target.x < Vector.x)
headingDegs -= DEG2RAD(180);
it will work for targets that are left & up, but not left & down. WHAT DO I DO LOL?
48
Name:
Anonymous
2008-11-17 8:08
>>47
This is why we
DONT HELP HIM!!! ;)
49
Name:
fairX the haxxor
2008-11-17 13:07
50
Name:
Anonymous
2008-11-17 13:36
51
Name:
Anonymous
2008-11-17 15:20
52
Name:
Anonymous
2008-11-18 5:05
get atan2 up all in that ho for the sign of your life
53
Name:
Anonymous
2008-11-18 5:33
54
Name:
Anonymous
2008-11-18 8:02
Why the fuck do you want the angle for this? Just normalize the delta between the two points to the speed you want.
P.S. And you still need 3 points to calculate an angle, saying the "angle between 2 points" is a fucking meaningless statement.
55
Name:
Anonymous
2008-11-18 9:28
>>54
Obviously,
he meant the angle between two vectors , dipshit.
56
Name:
Anonymous
2008-11-18 13:17
This problem is trivial given a mathematician.
57
Name:
Anonymous
2008-11-19 1:36
>>56
Not the useless ones I'm working with.
58
Name:
Anonymous
2009-03-06 7:49
Responder client closed ClientSock.
60
Name:
Anonymous
2010-11-26 13:19