Creates a geometry that represents a circle. Z values are set to 0. - CSharp System

CSharp examples for System:Math Geometry

Description

Creates a geometry that represents a circle. Z values are set to 0.

Demo Code


using System.Threading.Tasks;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System.Collections;
using System;//w  ww  .j a  va 2s  .c  o m
using Complexity.Math_Things;

public class Main{
        /// <summary>
        /// Creates a geometry that represents a circle. Z values are set to 0.
        /// </summary>
        /// <param name="points">The number of points to be calculated.
        /// Points are evenly spaced.</param>
        /// <returns></returns>
        public static double[,] Circle(int points) {
            double[,] result = new double[3, points];
            double t;

            for (int i = 0; i < points; i++) {
                t = ((double)i) / ((double)points);
                result[0, i] = Math.Sin(t * Math.PI * 2);
                result[1, i] = Math.Cos(t * Math.PI * 2);
                result[2, i] = 0;
            }

            return result;
        }
}

Related Tutorials