コード例 #1
0
        /// <summary>
        /// Generates a term that gets smaller as the given 2D point fits a 3D points set projection.
        /// </summary>
        /// <param name="pointsSet">A representation for the 3D points set</param>
        /// <param name="point">The 2D point</param>
        /// <returns>The term that measures fitness of <paramref name="point"/> being on the 2D projection of the set specified by <paramref name="pointsSet"/></returns>
        public static Term Compute(CircleFeatureCurve pointsSet, Point point)
        {
            // here we explicitly assume that the view vector is (0, 0, 1) or (0, 0, -1)
            var x_ = point.X;
            var y_ = point.Y;

            var cx = pointsSet.Center.X;
            var cy = pointsSet.Center.Y;
            var cz = pointsSet.Center.Z;

            var nx = pointsSet.Normal.X;
            var ny = pointsSet.Normal.Y;
            var nz = pointsSet.Normal.Z;

            var r = pointsSet.Radius;

            var dx = cx - x_;
            var dy = cy + y_;

            var lhs = TermBuilder.Sum(
                TermBuilder.Power(dx * nz, 2),
                TermBuilder.Power(dy * nz, 2),
                TermBuilder.Power(dx * nx + dy * ny, 2));
            var rhs = TermBuilder.Power(r * nz, 2);

            return(TermBuilder.Power(lhs - rhs, 2));
        }
コード例 #2
0
        public CircleFeatureVisual(CircleFeatureCurve featureCurve, double thickness = 0.01)
        {
            Contract.Requires(thickness > 0);
            Contract.Requires(featureCurve != null);
            Contract.Ensures(object.ReferenceEquals(featureCurve, FeatureCurve));

            this.featureCurve = featureCurve;
            this.thickness    = thickness;

            var emissiveMaterial = new EmissiveMaterial();

            emissiveMaterial.Bind(
                EmissiveMaterial.BrushProperty,
                () => featureCurve.IsSelected,
                isSelected => isSelected ? Brushes.DarkOrange : Brushes.Black);

            var material = new MaterialGroup();

            material.Children.Add(new DiffuseMaterial {
                Brush = Brushes.Black
            });
            material.Children.Add(emissiveMaterial);

            model3d          = new GeometryModel3D();
            model3d.Material = model3d.BackMaterial = material;
            Content          = model3d;

            Update();
        }
コード例 #3
0
        public static IEnumerable <Term> Compute(CircleFeatureCurve item)
        {
            const int SAMPLE_SIZE = 20;
            var       sample      = CurveSampler.UniformSample(item.SnappedTo, SAMPLE_SIZE);

            return(Compute(item, sample));
        }
コード例 #4
0
        protected IEnumerable <Term> ProjectionFit(CircleFeatureCurve item)
        {
            const int SAMPLE_SIZE = 10;
            var       sample      = CurveSampler.UniformSample(item.SnappedTo, SAMPLE_SIZE);

            return(ProjectionFit(item, sample));
        }
コード例 #5
0
        /// <summary>
        /// Generates a set of terms, one for each given 2D point, that measure the fitness of each point to being
        /// a 2D projection of the given set.
        /// </summary>
        /// <param name="pointsSet">A representation for the 3D points set</param>
        /// <param name="sample">The set of 2D points</param>
        /// <returns>The set of terms, one for each point in <paramref name="sample"/> that measures the fitness of each such point
        /// to the set in <paramref name="pointsSet"/>.</returns>
        public static IEnumerable <Term> Compute(CircleFeatureCurve pointsSet, Point[] sample)
        {
            var terms =
                from point in sample
                select Compute(pointsSet, point);

            return(terms);
        }
コード例 #6
0
        /// <summary>
        /// Generates a set of terms, one for each given 2D point, that measure the fitness of each point to being
        /// a 2D projection of the given set.
        /// </summary>
        /// <param name="pointsSet">A representation for the 3D points set</param>
        /// <param name="sample">The set of 2D points</param>
        /// <returns>The set of terms, one for each point in <paramref name="sample"/> that measures the fitness of each such point
        /// to the set in <paramref name="pointsSet"/>.</returns>
        protected IEnumerable <Term> ProjectionFit(CircleFeatureCurve pointsSet, Point[] sample)
        {
            var terms =
                from point in sample
                select ProjectionFit(pointsSet, point);

            return(terms);
        }
コード例 #7
0
        private Geometry GetGeometry(CircleFeatureCurve circle)
        {
            var circlePoints = ShapeHelper.GenerateCircle(circle.CenterResult,
                                                          circle.NormalResult,
                                                          circle.RadiusResult,
                                                          20);

            return(GetProjectedGeometry(circlePoints));
        }
コード例 #8
0
        protected Term EndpointsProjectionFit(CircleFeatureCurve pointsSet, Point p1, Point p2)
        {
            var x1 = p1.X;
            var y1 = -p1.Y;

            var x2 = p2.X;
            var y2 = -p2.Y;

            var cx = pointsSet.Center.X;
            var cy = pointsSet.Center.Y;
            var r  = pointsSet.Radius;

            var eq1 = TermBuilder.Power(x1 - cx, 2) + TermBuilder.Power(y1 - cy, 2) - TermBuilder.Power(r, 2);
            var eq2 = TermBuilder.Power(x2 - cx, 2) + TermBuilder.Power(y2 - cy, 2) - TermBuilder.Power(r, 2);

            var result = TermBuilder.Power(eq1, 2) + TermBuilder.Power(eq2, 2);

            return(result);
        }
コード例 #9
0
        private bool TryFindSingleFeatureCurveOnSphere(FeatureCurve[] selectedElements, out CircleFeatureCurve onSphere, out FeatureCurve other)
        {
            onSphere = selectedElements.OfType <CircleFeatureCurve>().FirstOrDefault(IsOwnedBySphere);
            other    = selectedElements.Where(x => !IsOwnedBySphere(x)).FirstOrDefault();

            return(other != null && onSphere != null);
        }