Member 13390774 Ответов: 0

Как создать класс android.graphics.circle? (Математическое Программирование пользовательского интерфейса)


В этом классе есть все, что я сделал до сих пор.



Цель: получить пересечение &амп; методы пересекаются функционирования

Я не самый великий математический Мастер и мог бы воспользоваться некоторой помощью с формулами и программными операциями, которые заставляют такие функции работать в резонансе, что этот класс является кругом, а не квадратом.



Вопрос:

Итак, как вы получите пересекаются, пересекаются, и содержит функции работы для круг для работы с кругами и круг для работы с прямоугольниками?



Спасибо!

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Android.App;
using Android.Content;
using Android.OS;
using Android.Runtime;
using Android.Util;
using Android.Views;
using Android.Widget;
using Android.Graphics;
using Android.Graphics.Drawables;

namespace Android.Graphics
{
    /// <summary>
    /// It is just a basic circle with properties that are editable, yet still binded together.
    /// </summary>
    public class Circle : IParcelable
    {        
        
        private Point centre;
        private Double area;
        private Double diameter;
        private Double radius;
        private Double circuference;
        public enum PropertySelector { Area, Diameter, Radius, Circumference };    
        
        /// <summary>
        /// Create A Cricle From Property-Value Relations.
        /// </summary>
        /// <param name="Property">Geometrical Property To Scale.</param>
        /// <param name="Value">The Size Of That Property</param>
        public Circle(PropertySelector Property, Double Value, Point Centre) {
            switch (Property)
            {
                case PropertySelector.Area:
                    this.Area = Value;
                    UpdateProperty(PropertySelector.Diameter, PropertySelector.Area);
                    UpdateProperty(PropertySelector.Radius, PropertySelector.Area);
                    UpdateProperty(PropertySelector.Circumference, PropertySelector.Area);
                    break;
                case PropertySelector.Diameter:
                    this.Diameter = Value;
                    UpdateProperty(PropertySelector.Area, PropertySelector.Diameter);
                    UpdateProperty(PropertySelector.Radius, PropertySelector.Diameter);
                    UpdateProperty(PropertySelector.Circumference, PropertySelector.Diameter);
                    break;
                case PropertySelector.Radius:
                    this.Radius = Value;
                    UpdateProperty(PropertySelector.Area, PropertySelector.Radius);
                    UpdateProperty(PropertySelector.Diameter, PropertySelector.Radius);
                    UpdateProperty(PropertySelector.Circumference, PropertySelector.Radius);
                    break;
                case PropertySelector.Circumference:
                    this.circuference = Value;
                    UpdateProperty(PropertySelector.Area, PropertySelector.Circumference);
                    UpdateProperty(PropertySelector.Diameter, PropertySelector.Circumference);
                    UpdateProperty(PropertySelector.Radius, PropertySelector.Circumference);
                    break;
            }
            this.centre = Centre;
        }

        public Circle(PropertySelector Property, Double Value) : this(Property, Value, new Point(0, 0)) { }
        public Circle(Point Centre) : this(PropertySelector.Radius, 12, Centre) { }
        public Circle() : this(PropertySelector.Radius, 12, new Point(0, 0)) { }
        public Circle(Circle C)
        {
            this.area = C.Area;
            this.centre = C.Centre;
            this.circuference = C.Circumference;
            this.diameter = C.Diameter;
            this.radius = C.Radius;
        }
        /// <summary>
        /// Calculates A Given Property From Another Property.
        /// </summary>
        /// <param name="Property">The Property To Figure.</param>
        /// <param name="From">The Property To Figure From.</param>
        /// <param name="Value">The Value Of The Property To Figure From.</param>
        /// <returns>Value Of The Property Figured.</returns>
        public static double Calc(PropertySelector Property, PropertySelector From, double Value)
        {
            switch (Property)
            {
                case PropertySelector.Area:
                    switch (From)
                    {
                        case PropertySelector.Area: // Calculate Area From Area
                            return Value;
                        case PropertySelector.Circumference: // Find The Area, Given Circumference
                            return Math.Pow(Value, 2) / (4 * Math.PI);
                        case PropertySelector.Diameter: // Find The Area, Given The Diameter
                            return Math.PI * (Value / 2) * (Value / 2);
                        case PropertySelector.Radius: // Find Area, Given Radius
                            return Math.PI * Value * Value;

                    }
                    break;
                case PropertySelector.Circumference:
                    switch (From)
                    {
                        case PropertySelector.Area:// Circumference From Area
                            return (2 * Math.PI) * Math.Sqrt(Value / Math.PI);
                        case PropertySelector.Circumference: // Circumference From Circumference
                            return Value;
                        case PropertySelector.Diameter: // Circumference From Diameter
                            return 2 * Math.PI * (Value / 2);
                        case PropertySelector.Radius: // Circumference From Radius
                            return 2 * Math.PI * Value;
                    }
                    break;
   
                case PropertySelector.Diameter:
                    switch (From)
                    {
                        case PropertySelector.Area: // Calculate Diameter Of Circle, Given Its Area
                            return Math.Sqrt(Value / Math.PI) * 2;
                        case PropertySelector.Circumference: // Calculate Diameter Of Circle, Given Its Circumference
                            return Value / Math.PI;
                        case PropertySelector.Diameter: // Calculate Diameter Of Circle, Given Its Diameter
                            return Value;
                        case PropertySelector.Radius: // Calculate Diameter Of Circle, Given Its Radius
                            return 2 * Value;
                    }
                    break;
                case PropertySelector.Radius:
                    switch (From)
                    {
                        case PropertySelector.Area: // Calculate Raduis From Area
                            return Math.Sqrt(Value / Math.PI);
                        case PropertySelector.Circumference: // Calculate Radius From Circumference
                            return (Value / Math.PI) / 2;
                        case PropertySelector.Diameter: // Calculate Radius From Diameter
                            return Value / 2;
                        case PropertySelector.Radius: // Calculate Radius From Radius
                            return Value;
                    }
                    break;
            }
            throw new Exception("Should not have happened...");
        }

        /// <summary>
        /// Updates One Property From Another Property Of The Same Class.
        /// </summary>
        /// <param name="Property">The Property To Be Updated</param>
        /// <param name="From">Update That Property From This Property</param>
        private void UpdateProperty(PropertySelector Property, PropertySelector From)
        {
            Double Value = 0;
            switch (From)
            {
                case PropertySelector.Area:
                    Value = area;
                    break;
                case PropertySelector.Diameter:
                    Value = diameter;
                    break;
                case PropertySelector.Radius:
                    Value = radius;
                    break;
                case PropertySelector.Circumference:
                    Value = circuference;
                    break;
            }

            Value = Calc(Property, From, Value);

            switch (Property)
            {
                case PropertySelector.Area:
                    area = Value;
                    break;
                case PropertySelector.Diameter:
                    diameter = Value;
                    break;
                case PropertySelector.Radius:
                    radius = Value;
                    break;
                case PropertySelector.Circumference:
                    circuference = Value;
                    break;
            }
        }

        /// <summary>
        /// Get or set the circle by it's diameter.
        /// </summary>
        public Double Diameter
        {
            get
            {
                return diameter;
            }
            set
            {
                this.diameter = value;
                UpdateProperty(PropertySelector.Area, PropertySelector.Diameter);
                UpdateProperty(PropertySelector.Circumference, PropertySelector.Diameter);
                UpdateProperty(PropertySelector.Radius, PropertySelector.Diameter);
            }
        }

        /// <summary>
        /// Get or set the circle by it's radius.
        /// </summary>
        public Double Radius
        {
            get
            {
                return this.radius;
            }
            set
            {
                this.radius = value;
                UpdateProperty(PropertySelector.Area, PropertySelector.Radius);
                UpdateProperty(PropertySelector.Circumference, PropertySelector.Radius);
                UpdateProperty(PropertySelector.Diameter, PropertySelector.Radius);
            }
        }

        /// <summary>
        /// Binds into radius, the values are just that equal on an object that is of infinate and no space.
        /// </summary>
        public Point Centre
        {
            get
            {
                return this.centre;
            }
            set
            {
                this.centre = value;
            }
        }

        /// <summary>
        /// Get or set the circle by it's area.
        /// </summary>
        public Double Area
        {
            get
            {
                return this.area;
            }
            set
            {
                this.area = value;
                UpdateProperty(PropertySelector.Circumference, PropertySelector.Area);
                UpdateProperty(PropertySelector.Diameter, PropertySelector.Area);
                UpdateProperty(PropertySelector.Radius, PropertySelector.Area);
            }
        }

        /// <summary>
        /// Get or set the circle by it's circumference.
        /// </summary>
        public Double Circumference
        {
            get
            {
                return this.Circumference;
            }
            set
            {
                this.Circumference = value;
                UpdateProperty(PropertySelector.Area, PropertySelector.Circumference);
                UpdateProperty(PropertySelector.Diameter, PropertySelector.Circumference);
                UpdateProperty(PropertySelector.Radius, PropertySelector.Circumference);
            }
        }

        public Boolean isEmpty()
        {
            return true;
        }

        public void offset(int dx, int dy)
        {
            throw new NotImplementedException();
        }

        public void offsetTo(int newLeft, int newTop)
        {
            throw new NotImplementedException();
        }

        public void readFromParcel(Parcel _in)
        {
            throw new NotImplementedException();
        }

        public void set(Circle src)
        {
            throw new NotImplementedException();
        }

        public void set(PropertySelector Property, Double Value, Point Centre)
        {
            throw new NotImplementedException();
        }

        public void setEmpty()
        {
            throw new NotImplementedException();
        }

        public Boolean setIntersect(Circle a, Circle b)
        {
            throw new NotImplementedException();
        }

        public Boolean setIntersect(Circle a, Rect b)
        {
            throw new NotImplementedException();
        }

        public Boolean setIntersect(Circle a, int left, int top, int right, int bottom)
        {
            throw new NotImplementedException();
        }

        public void sort()
        {
            throw new NotImplementedException();
        }

        public String toShortString()
        {
            throw new NotImplementedException();
        }

        public String toString()
        {
            throw new NotImplementedException();
        }

        public static Circle unflattenFromString(String str)
        {
            throw new NotImplementedException();
        }


        public void union(PropertySelector Property, Double Value, Double Centre)
        {
            throw new NotImplementedException();
        }

        public void union(Circle c)
        {
            throw new NotImplementedException();
        }

        public void union(int left, int top, int right, int bottom)
        {
            throw new NotImplementedException();
        }

        public void union(Rect r)
        {
            throw new NotImplementedException();
        }

        public void union(int x, int y)
        {
            throw new NotImplementedException();
        }

        public Double Width
        {
            get
            {
                return diameter;
            }
        }


        public Double Height
        {
            get
            {
                return diameter;
            }
        }

        public IntPtr Handle => throw new NotImplementedException();

        public static Boolean Intersect(Circle Circle1, int left, int top, int right, int bottom)
        {
            throw new NotImplementedException();
        }

        public static Boolean Intersect(Circle Circle, Rect Rect)
        {
            throw new NotImplementedException();
        }

        public static Boolean Intersect(Circle Circle1, Circle Circle2)
        {
            throw new NotImplementedException();
        }

        public Boolean Intersect(Circle Circle)
        {
            throw new NotImplementedException();
        }

        public int DescribeContents()
        {
            throw new NotImplementedException();
        }

        public void WriteToParcel(Parcel dest, [GeneratedEnum] ParcelableWriteFlags flags)
        {
            throw new NotImplementedException();
        }

        public void Dispose()
        {
            throw new NotImplementedException();
        }
    }


   

}


Что я уже пробовал:

Я разработал класс с этого момента, и после этого я достиг точки, когда я даже не мог читать алгебраические или тригонометрические выражения, которые я читал в интернете. Для меня это было даже отдаленно непонятно. Вот почему я прошу помощи на:

общественного недействительными пересекаются(круг)
public bool Intersect (круг, квадрат)
public bool Intersect(Circle, Circle)
public float Contains (Square) { ...//возвращает процент содержания квадратного круга) }
public float содержит(Circle) { ...//то же самое для квадрата, но с кругом вместо него. }

Речь идет о математике геометрии.

Спасибо!

0 Ответов