Exemple #1
0
        //
        // Resumen:
        //     For a given point returns the closest point on the plane.
        //
        // Parámetros:
        //   point:
        //     The point to project onto the plane.
        //
        // Devuelve:
        //     A point on the plane that is closest to point.
        public Vec3 ClosestPointOnPlane(Vec3 point)
        {
            float distance = Vec3.Dot(point - a, normal) / Vec3.Magnitude(normal);
            Vec3  vector   = normal.normalized * distance;

            return(point + vector);
        }
Exemple #2
0
        public Enalp(Vec3 a, Vec3 b, Vec3 c)
        {
            this.a = a;
            this.b = b;
            this.c = c;

            Vec3 side1 = b - a;
            Vec3 side2 = c - a;

            normal   = Vec3.Cross(side1, side2);
            distance = Vec3.Dot(-a, normal) / Vec3.Magnitude(normal);
            flipped  = -normal;
        }
Exemple #3
0
        public Enalp(Vec3 inNormal, Vec3 inPoint)
        {
            Vec3 normalPerp1 = new Vec3(inNormal.y, -inNormal.x, 0);
            Vec3 normalPerp2 = new Vec3(inNormal.z, 0, -inNormal.x);

            this.a = inPoint;
            this.b = a + normalPerp1;
            this.c = a + normalPerp2;

            normal   = inNormal;
            distance = Vec3.Dot(-a, normal) / Vec3.Magnitude(normal);
            flipped  = -normal;
        }
Exemple #4
0
        void Update()
        {
            if (Input.GetMouseButtonDown(0))
            {
                startTime     = Time.time;
                target        = new Vec3(Input.mousePosition);
                journeyLength = Vec3.Magnitude(target - positionVec3);

                proyectiles.Add(GameObject.CreatePrimitive(PrimitiveType.Sphere));
                proyectiles[0].transform.position    = transform.position;
                proyectiles[0].transform.localScale /= 10;
            }

            if (proyectiles[0])
            {
                distCovered = (Time.time - startTime) * speed;

                fractionOfJourney = distCovered / journeyLength;

                proyectiles[0].transform.position = Vec3.Lerp(positionVec3, target, 0.001f);
            }
        }
Exemple #5
0
 //
 // Resumen:
 //     Returns a signed distance from plane to point.
 //
 // Parámetros:
 //   point:
 public float GetDistanceToPoint(Vec3 point)
 {
     return(distance = Vec3.Dot(point - a, normal) / Vec3.Magnitude(normal));
 }