I am trying to measure angle between points shoulder, hip and ankle (to identify how much lift person's leg). When the person stands on front of the camera it works well but when the person turns sideways it fails. How can I handle it?
Related
I'm trying to make a character that walks around a platform and if the character reach a corner, it rotates and continue walking on the side of the platform, same with the bottom part.
This is a visual representation of what I'm trying to achive.
Movement
The specific problem is when the character reach the corners, the rotation just go crazy. I'm trayng to achive this using a raycast from the character to the platform and if the raycast doesn't find floor, I start the rotation like this:
times++;
transform.rotation = Quaternion.Slerp(transform.rotation,Quaternion.AngleAxis(times*-89.9f,Vector3.forward),Time.deltaTime * RotationSpeed);
_characterGravity.SetGravityAngle(transform.localEulerAngles.z);
I'm using a characterGravity script that allows me to change the gravity direction for the character in order to not fall when is walking upside down or on the sides. But this is not working propperly. Is there a better way to do this?
Assuming your 2D view is aligned on the X-Y plane, with the Z-axis aimed into the screen (the same direction the camera is facing), I suggest using Transform.Rotate() instead of trying to linearly interpolate the rotation between two values:
if (ShouldRotateAroundCorner()) {
transform.Rotate(Vector3.forward, RotationSpeed * Time.deltaTime);
}
You'll just need to make sure your ShouldRotateAroundCorner() knows when to start and stop the 90 degree turn, which will take a little bit of additional code to keep track of when it's in this state change.
I am planning to develop a program in MATLAB/Python that can detect the coordinate of any point in space that a person is looking at. I was hoping to do it by placing a headset with a camera installed before eyes and tracking the pupil of the both eyes. I still don't know if it is possible. That's why I need help.
This is a challenging task.
To some extent, you can determine the outline of the pupils, and a little of the iris, by image processing. Then fitting an ellipse to these and a little geometry from the ellipse axis gives you an approximate direction of gaze. Then drawing two rays from the eyes and following these directions will give you a point of convergence.
The coordinates you will obtain will be relative to the image plane, i.e. to the position of the camera, which will move with the head.
Anyway, exact outlining of ellipses will be inaccurate, the rays will fail to cross exactly, cornea refraction and perspective will alter the measurements, the glasses will move a little, and so on.
I have been working on a Unity ping pong game using the Leap Motion. I use rigidbody.MovePosition() to move the paddle. However, when I hit the ball (which uses gravity), the paddle launches it too far. Even when I change the masses of both, it doesn't do anything.
What variable should I change to reduce this energy going into the ball?
From the following link.
"MovePosition will put your object at the target location, no matter what. It may push aside other objects in a realistic way, or may blast them out of the way, or may just pass right through them. But it will gladly move you through a solid wall or a mountain.
If you're using MovePosition on a rigidbody to add from where you currently are, it looks like AddForce. With AddForce, the physics step does all the work: applies your velocity, sees the collision and handles the bounce. With MovePosition, the physics step sees you're mysteriously overlapping a solid object. If it isn't too much, it will bounce you apart."
You won't need to use MovePosition. Instead, you can figure out the direction of the shot (based on the position of the ball relative to the paddle). Then you can add an impulse force in that direction to the ball.
Pseudo-code (from the following link):
Vector3 shootDir = ballPosition - paddlePosition; // Calculate direction of the shot
shootDir.Normalize(); // Normalize the shot vector
ball.AddForce(shootDir * speed, ForceMode.Impulse); //Add impulse force in correct direction.
Credit due to Owen Reynolds and Tim Michels.
I use Unity3D and I have a player with a rigidbody. I add force tto the body for moving the player. My player walks over a terrain but is able to walk up mountains that are to steep to climb. I want to limit the player so it cannot walk up a slope that is to steep.
I know there is a CharacterController component that has this functionality, but I have to use the rigidbody, so I want the same but on my rigidbody.
I can get the normal of the triangle I am standing on, and calculate its angle, but I cannot seem to make the player stop moving up the slope. Only make the player stop moving (which makes the player unmovable once it hits a angled slope)
Any ideas how to solve this problem?
It's difficult to answer without more details on how you're using the physics engine. How/Are you using friction? What angle are you applying the force? Is it always horizontal or at the angle of the floor? Does the player have a mass?
Anyway I can think of a few ways to solve this
Go the pure physics route. Using player mass, friction, force angle, gravity, etc. Get the physics to handle these situation for you. This may take a fair amount of time and programming.
Keep the rigid body but fake the forces. Scale the force you are applying to the body of the player with the angle of the triangle the player is on. You can either use trigonometry to work out what you should apply or your own mapping. By your own mapping I mean set an angle where 0 force is applied (say 45 degree) and do a linear(or non linear) scale on the force applied so on flat ground force is 1 and at 45 force is 0.
Don't use rigid bodies. There is a reason most games don't use rigid bodies to control characters. It's hard and complicated and most of the time not worth the time it would take. Of course I don't know the details of your project so if this isn't an option, fine.
Hope that gives you some things to think about.
I was wondering if anyone could help me get started or pointed in the right direction. I'm looking to make a simple driving game using core animation. I'm a pretty good obj-c programmer, but when it comes to movement and math, I fail. I want a steering wheel to control the direction of the car, and a forward/backward to control acceleration & deceleration. If anyone can help me with the steering wheel code, I would be greatly appreciated! So basically I need help making a circle that can rotate with 1 finger drag, and i'll pass it's transform values to my car view ( i think i can handle the accel/deccel code) Any takers? :) Also, I have 2 invites for dribbble.com to give away, anyone who helps me, id be glad to give one out to.
grady, totowtwo, thanks for both your answers, I appreciate it. I;ve gotten to the point where I can rotate a "steering wheel" and it will rotate my "car", I also got it to move forwards and backwards. Just need to moving to be more realistic... Here is a link to the xCode project, http://www.cl.ly/7VBU, kept it very simple so if anyone looks at it - it will be easy to change / add code. So, if anyones wants to look at it,and help me make the movement more realistic, i'd be forever in your debt! :) thanks!
A starting point would be to recognize that a typical car steering wheel has 900 degrees of movement, whether you want that for the finger wheel or not is a design decision. The wheels in a car typically point about 30 degrees off +z at maximum rotation of the wheel. You could use a simple linear transformation from steering wheel angle to wheel angle.
From there, Car delta angle is a function of wheel angle times forward distance. As the car moves forward, you can imagine tracing the tangent of a circle with an infinite radius when you are pointing straight ahead, and a circle of smaller radius (~4x car length) when steering wheel is full tilt.
Of course, feel free to discard the design rules of typical vehicles. Give your users fun drive trains like holonomic robots have!
I am no expert but you could probably do something like:
CGPoint centerOfWheel;
CGPoint currentTouchPoint;
float radians = atan2(currentTouchPoint.x-centerOfWheel.x, currentTouchPoint.y-centerOfWheel.y);
then apply the transformation to the wheel ... of course you will want to make the transformations cumulative on the view over a distance, as continued turning of the wheel will result in continued turning.
also to make it feel more real, and less responsive you may want to use a lesser degree of turn, so that turning the wheel in once circle doesn't result in a whole circle turn of the vehicle. you will have to play around.