Exemple #1
0
 /// <summary>
 /// Compare two triangles and return true if equal
 /// </summary>
 /// <param name="tri">the other triangles to compare with</param>
 /// <returns>true if the two triangles equals, false otherwise</returns>
 public bool Equals(Triangle2DF tri)
 {
     return
         ((V0.Equals(tri.V0) || V0.Equals(tri.V1) || V0.Equals(tri.V2)) &&
          (V1.Equals(tri.V0) || V1.Equals(tri.V1) || V1.Equals(tri.V2)) &&
          (V2.Equals(tri.V0) || V2.Equals(tri.V1) || V2.Equals(tri.V2)));
 }
Exemple #2
0
        public override bool Equals(object obj)
        {
            if (obj is Edge other)
            {
                return((V1.Equals(other.V1) || V1.Equals(other.V2)) &&
                       (V2.Equals(other.V1) || V2.Equals(other.V2)) &&
                       Weight.Equals(other.Weight));
            }

            return(false);
        }
        /// <summary>
        /// returns a value from 0 - 255 based on how the given lightsource will light up the face
        /// 0 means its facing the entirely wrong way
        /// 127 means its perpendicular to the light
        /// 255 means its directly facing the light.
        /// </summary>
        /// <param name="lightSrc"></param>
        /// <returns></returns>

        /*public int Reflectivity(Light lightSrc)
         * {
         *  Point3D normal = Normal;
         *  Point3D lightVector = (this.Center - lightSrc.Location);
         *  float dotProduct; // cosine of the angle between the normal and the lightsource (from -1 to 1)
         *  dotProduct = (normal * lightVector) / (lightVector.Magnitude * normal.Magnitude);
         *
         *  float temp = (1 + dotProduct) / 2; //max(2/2) = 1, min = (0/2) = 0
         *  return (int)(temp * 255);
         * }
         *
         * public float getLightValue(List<Light> lightSrc)
         * {
         *  float lightVal = 0;
         *  foreach (Light l in lightSrc)
         *  {
         *      int reflect = Reflectivity(l);
         *
         *      if (reflect >= 128) // 128 -> 255 means face normal is pointing towards lightsource in some way.
         *      {
         *          float maxDistance = 1000 * l.Intensity;
         *          float light_triangle_dist = (this.Center - l.Location).Magnitude;
         *          //lightVal += l.Intensity * (reflect - 127) / (light_triangle_dist * light_triangle_dist);
         *          //lightVal += 255 - (l.Intensity * (255 - reflect) * (1 / Math.Max(light_triangle_dist, 1)));
         *          lightVal += (float)Math.Max(0, l.Intensity * ((reflect - 127) * 2) * -((light_triangle_dist - maxDistance) / maxDistance));
         *          lightVal = Math.Min(255, lightVal); // don't go over 255!
         *
         *      }
         *  }
         *  return Math.Min(255,lightVal+15);
         * }*/

        public bool HasVertex(Point3D v)
        {
            return(V1.Equals(v) || V2.Equals(v) || V3.Equals(v));
        }
 public bool Equals(Triangle3D other)
 {
     return(V1.Equals(other.V1) && V2.Equals(other.V2) && V3.Equals(other.V3));
 }