2 vectors difference to rotation

I have been throwing my head at this problem for a long time, and I am at the top, not understanding this.

Problem:

Currently trying to make a fake "swing" moment. When I have a player object that becomes a child object that you can snap during the keyboard.

With that in mind, I need to get the correct rotation in grappleobject by making the player speed the correct rotation in grappleobject.

This should not be 2D, but 3D. It causes a headache.

http://img843.imageshack.us/img843/7434/rotations.jpg

I thought that if I could get the position vector and the direction vector where the player is going, as well as the speed of the characterโ€™s engine, get a unique Vector, and this vector information should be able to correctly rotate the graft block.

However, this is what I thought was easy, but I cracked it several times to get this difference in vectors, to make a turn, as it was thought.

TL: dr

2 Vectors, the difference of these two by one vector, this vector controls the rotation of the grapple-like object to "fake" the oscillatory motion at the proper speed.

Thanks in advance if there will be an answer.

Information added:

Current tests were like that.

///

Parent Orb is a grappleobjects that updates its conversion depending on trigger events.
CurDirection is where the player moves inside the vector in the world.
CurPos is where the player is at that moment in time in the world.

CurDirection = (transform.position-ParentOrb.position); CurDirection.Normalize(); motor.movement.velocity = (CurDirection); CurPos = transform.position; 

////

Also tried to get the angle from grappleobject to the player.

///

otherDirection = direction of speed in space.
OtherDirectionPre = Current position in space.

  Vector3 targetDir = otherDirection; Vector3 forward = otherDirectionPre; angle = Vector3.Angle(targetDir, forward); 

/// I suppose this may not be very useful, but itโ€™s better to show where I am so far.

+4
source share
1 answer

I think you know the radius between the hit point and the center, call him r. With the playerโ€™s speed v and the angular ฯ‰ (= omega) axis speed, to which the player should be connected, you have the vector equation:

v = ฯ‰ ร— r

Assuming all 3 vectors are perpendicular to each other, you have ฯ‰ = v / r.

EDIT: You get the radius r from the center position and the point of contact of your collision:

 Vector3 r = collision.contacts[0].point - center; float radius = r.magnitude; float angularSpeed = rigidbody.veloctiy.magnitude / radius; 
+1
source

All Articles