public SolidColorBrush RgbLigth(SolidColorBrush color, IFacet face, IEnumerable <double> viewVector, bool kostil = false)
        {
            var enumerable = viewVector as IList <double> ?? viewVector.ToList();
            var cos        = FaceParameter.GetCos(FaceParameter.GetNormal(face),
                                                  FaceParameter.GetViewVector(new Vertex()
            {
                X = enumerable[0],
                Y = enumerable[1],
                Z = enumerable[2]
            },
                                                                              FaceParameter.GetCenter(face)));
            //if (face.NameFigure == nameof(Parallelepiped) && kostil)
            //{
            //    if (enumerable[1] == 5000)
            //    {
            //        return new SolidColorBrush(Color.FromRgb(0, 0, 0));
            //    }
            //}
            double light = Ia * Ka + Il * Kd * cos;

            light = light < 0 ? 0 : light > 255 ? 255 : light;
            if (enumerable[2] == 0)
            {
                light = 255 - light;
            }
            var    res      = light / 255;
            double r        = color.Color.R * res;
            double g        = color.Color.G * res;
            double b        = color.Color.B * res;
            var    newColor = new SolidColorBrush(Color.FromRgb((byte)r,
                                                                (byte)g,
                                                                (byte)b));

            return(newColor);
        }
Beispiel #2
0
        /// <summary>
        /// Hide lines
        /// </summary>
        /// <param name="facets">Collection of facets</param>
        /// <param name="vertex">View point</param>
        /// <returns></returns>
        public IEnumerable<IFacet> HideLines(IEnumerable<IFacet> facets, IVertex vertex)
        {
            var collection = facets;
            var compositeEntities = collection as IList<IFacet> ?? collection.ToList();

            foreach (var compositeEntity in compositeEntities)
            {
                compositeEntity.Normal = FaceParameter.GetNormal(compositeEntity);
                compositeEntity.Center = FaceParameter.GetCenter(compositeEntity);
                compositeEntity.ViewVector = FaceParameter.GetViewVector(vertex, compositeEntity.Center);
                compositeEntity.IsHidden = IsHiddenCoord(compositeEntity.Normal, compositeEntity.ViewVector);
            }
            return compositeEntities;
        }