Exemplo n.º 1
0
        public Vector lerp(float t)
        {
            t = type == LineType.Segment ? MainMath.clamp(t, 0, 1) : type == LineType.Ray ? MainMath.clamp(t, 0, Mathf.Infinity)
                  : MainMath.clamp(t, -Mathf.Infinity, Mathf.Infinity);

            return((A + V) * t);
        }
Exemplo n.º 2
0
        public bool doesLineIntersect(Line other)
        {
            if (MainMath.dotProduct(Vector.pepedincular(other.V), V) == 0)
            {
                return(false);
            }

            float time; // t is a point in this line where other intersects at

            Vector this_line  = this.toVector();
            Vector other_line = other.toVector();

            Vector this_line_pepedincular  = Vector.pepedincular(this_line);
            Vector other_line_pepedincular = Vector.pepedincular(other_line);

            time = MainMath.dotProduct(other_line_pepedincular, (other.A - this.A)) / MainMath.dotProduct(other_line_pepedincular, this_line);

            if ((time < 0 || time > 1) && type == LineType.Segment)
            {
                return(false);
            }

            return(true);
        }