<commit_before>﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace CSharpGL
{

    public class AnnulusModel : IBufferSource, IObjFormat
    {
        private vec3 modelSize;
        public vec3 ModelSize()
        {
            return this.modelSize;
        }

        public AnnulusModel(float radius, float thickness, uint sliceCount, uint secondSliceCount)
        {
            {
                var positions = new vec3[sliceCount * secondSliceCount];
                int t = 0;
                var y = new vec3(0, 1, 0);
                for (int i = 0; i < sliceCount; i++)
                {
                    double di = 2 * Math.PI * i / sliceCount;
                    var center = new vec3(radius * (float)Math.Sin(di), 0, radius * (float)Math.Cos(di));
                    float length = center.length();
                    center = center.normalize();
                    for (int j = 0; j < secondSliceCount; j++)
                    {
                        double dj = 2 * Math.PI * j / secondSliceCount;
                        positions[t++] = center * (length - thickness * (float)Math.Cos(dj))
                            + y * (thickness * (float)Math.Sin(dj));
                    }
                }
                BoundingBox box = positions.Move2Center();
                this.positions = positions;
                this.modelSize = box.MaxPosition - box.MinPosition;
            }
            {
                var indexes = new uint[sliceCount * (secondSliceCount * 3 + secondSliceCount * 3)];
                uint t = 0;
                for (uint i = 0; i < sliceCount - 1; i++)
                {
                    for (uint j = 0; j < secondSliceCount; j++)
                    {
                        indexes[t++] = i * secondSliceCount + j;
                        indexes[t++] = i * secondSliceCount + (j + 1) % secondSliceCount;
                        indexes[t++] = i * secondSliceCount + secondSliceCount + (j + 1) % secondSliceCount;

                        indexes[t++] = i * secondSliceCount + j;
                        indexes[t++] = i * secondSliceCount + secondSliceCount + (j + 1) % secondSliceCount;
                        indexes[t++] = i * secondSliceCount + secondSliceCount + (j + 2) % secondSliceCount;
                    }
                }
                {
                    uint i = sliceCount - 1;
                    for (uint j = 0; j < secondSliceCount; j++)
                    {
                        indexes[t++] = i * secondSliceCount + j;
                        indexes[t++] = i * secondSliceCount + (j + 1) % secondSliceCount;
                        indexes[t++] = (j + 1) % secondSliceCount;

                        indexes[t++] = i * secondSliceCount + j;
                        indexes[t++] = (j + 1) % secondSliceCount;
                        indexes[t++] = (j + 2) % secondSliceCount;
                    }
                }
                this.indexes = indexes;
            }
        }

        private readonly vec3[] positions;<commit_msg>AnnulusModel<commit_after>﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace CSharpGL
{

    public class AnnulusModel : IBufferSource, IObjFormat
    {
        private vec3 modelSize;
        public vec3 ModelSize()
        {
            return this.modelSize;
        }

        public AnnulusModel(float radius, float thickness, uint sliceCount, uint secondSliceCount)
        {
            {
                var positions = new vec3[sliceCount * secondSliceCount];
                int t = 0;
                var y = new vec3(0, 1, 0);
                for (int i = 0; i < sliceCount; i++)
                {
                    double di = 2 * Math.PI * i / sliceCount;
                    var center = new vec3(radius * (float)Math.Sin(di), 0, radius * (float)Math.Cos(di));
                    float length = center.length();
                    center = center.normalize();
                    for (int j = 0; j < secondSliceCount; j++)
                    {
                        double dj = 2 * Math.PI * j / secondSliceCount;
                        positions[t++] = center * (length - thickness * (float)Math.Cos(dj))
                            + y * (thickness * (float)Math.Sin(dj));
                    }
                }
                BoundingBox box = positions.Move2Center();
                this.positions = positions;
                this.modelSize = box.MaxPosition - box.MinPosition;
            }
            {
                var indexes = new uint[sliceCount * (secondSliceCount * 3 + secondSliceCount * 3)];
                uint t = 0;
                for (uint i = 0; i < sliceCount; i++)
                {
                    for (uint j = 0; j < secondSliceCount; j++)
                    {
                        indexes[t++] = i * secondSliceCount + j;
                        indexes[t++] = i * secondSliceCount + (j + 1) % secondSliceCount;
                        indexes[t++] = (i * secondSliceCount + secondSliceCount + (j + 1) % secondSliceCount) % (sliceCount * secondSliceCount);

                        indexes[t++] = i * secondSliceCount + j;
                        indexes[t++] = (i * secondSliceCount + secondSliceCount + (j + 1) % secondSliceCount) % (sliceCount * secondSliceCount);
                        indexes[t++] = (i * secondSliceCount + secondSliceCount + j) % (sliceCount * secondSliceCount);
                    }
                }
                this.indexes = indexes;
            }
        }

        private readonly vec3[] positions;
{'fraction_non_alphanumeric': 0.10516965713270564, 'fraction_numerical': 0.009948481080120803, 'mean_word_length': 1.2619525914021696, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1788511', 'n_tokens_mistral': 1549, 'n_tokens_neox': 1396, 'n_words': 375}