What's new
  • Visit Rebornbuddy
  • Visit Panda Profiles
  • Visit LLamamMagic
  • Visit Resources
  • Visit Downloads
  • Visit Portal

How can I get an X, Y, Z coordinate between me and object?

user01

Member
Joined
Sep 19, 2014
Messages
71
Reaction score
0
I've been trying to find a formula that would help me , but I seem unable to find anything. I'd like to get an X,Y,Z coordinate between me and an object with maybe a variable distance. Does anyone have some code I can look at?


Thanks,
user
 
Distance:
Code:
A(xa, ya) and B(xb, yb)
       ___________________
AB = √(xb - xa)² + (yb - ya)²
Code:
    public class Point3D
    {
        private double x, y, z;

        private string name = String.Empty;

        private double radius = 0.4;

        public double X { get { return x; } set { x = value; } }
        public double Y { get { return y; } set { y = value; } }
        public double Z { get { return z; } set { z = value; } }

        public string Name { get { return name; } set { name = value; } }

        public double Radius
.......
public static double Dist3D(Point3D P1, Point3D P2)
{
     return Math.Sqrt((P1.X - P2.X) * (P1.X - P2.X) + (P1.Y - P2.Y) * (P1.Y - P2.Y) + (P1.Z - P2.Z) * (P1.Z - P2.Z));
}
public static double Dist2D(Point3D P1, Point3D P2)
{
     return Math.Sqrt((P1.X - P2.X) * (P1.X - P2.X) + (P1.Y - P2.Y) * (P1.Y - P2.Y));
}
public static double Dist2D_no_Radius(Point3D P1, Point3D P2)
{
     return Math.Sqrt((P1.X - P2.X) * (P1.X - P2.X) + (P1.Y - P2.Y) * (P1.Y - P2.Y))-P1.Radius-P2.Radius;
}
......
X,Y,Z me and object.

Code:
 Point3D me,object,meAndObject;
 .....
 meAndObject.X  = (me.X+object.X) / 2;
 meAndObject.Y = (me.Y+object.Y) / 2;
 meAndObject.Z  = (me.Z+object.Z) / 2;
 
Last edited:
Back
Top