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);
        }
Esempio n. 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;
        }
Esempio n. 3
0
        public IActionResult Post([FromQuery] string query, [FromBody] FaceParameter faceParameter)
        {
            const string baseUrl = "https://westeurope.api.cognitive.microsoft.com/";
            const string key     = "12698d847341459a89a7fe8901eafc39";

            var httpClient = new HttpClient {
                BaseAddress = new Uri(baseUrl)
            };

            httpClient.DefaultRequestHeaders.Add("Ocp-Apim-Subscription-Key", key);
            httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));

            var json          = JsonConvert.SerializeObject(faceParameter);
            var stringContent = new StringContent(json, Encoding.UTF8, "application/json");

            var url = $"face/v1.0/detect?{query}";

            var response = httpClient.PostAsync(url, stringContent).Result;

            var content = response.Content.ReadAsStringAsync().Result;

            return(Ok(JArray.Parse(content)));
        }
Esempio n. 4
0
 private static bool IsHiddenCoord(IEnumerable<double> a, IEnumerable<double> b)
 {
     var cos = FaceParameter.GetCos(a, b);
     return cos < 0.001;
 }