Canguro.Commands.Model.AddCylinderCmd.createCylinder C# (CSharp) Method

createCylinder() protected method

Creates a cylinder and adds it to the model.
protected createCylinder ( Canguro model, System.Vector3 C, float radius, int cols, float height, int stories, StraightFrameProps props ) : void
model Canguro The Model object
C System.Vector3 The Center of the base
radius float The radius
cols int Number of columns
height float Height of each story
stories int Number of stories
props Canguro.Model.StraightFrameProps Frame properties to use in all elements
return void
        protected void createCylinder(Canguro.Model.Model model, Vector3 C, float radius, int cols, float height, int stories, StraightFrameProps props)
        {
            float[,] columns = new float[cols, 3];
            int i, f, c;
            Queue<Joint> jQueue = new Queue<Joint>();
            Joint joint, first, prev;
            joint = prev = first = null;
            LineElement line;

            double angle, delta = 2 * Math.PI / (double)cols;
            float[] angles = new float[cols];

            for (i = 0, angle = 0; i < cols; angle += delta, i++)
            {
                columns[i, 0] = (float)(C.X + Math.Cos(angle) * radius);
                columns[i, 1] = (float)(C.Y + Math.Sin(angle) * radius);
                columns[i, 2] = (float)C.Z;
                angles[i] = (float)(angle * 180.0 / Math.PI);
            }

            JointDOF baseDoF = new JointDOF();
            baseDoF.T1 = baseDoF.T2 = baseDoF.T3 = JointDOF.DofType.Restrained;
            for (f = 0; f < stories; f++)
            {
                for (c = 0; c < cols; c++)
                {
                    joint = new Joint(columns[c, 0], columns[c, 1], columns[c, 2] + height * f);
                    if (c == 0) first = joint;
                    if (f == 0) joint.DoF = baseDoF;
                    model.JointList.Add(joint);
                    jQueue.Enqueue(joint);
                    if (f > 0)
                    {
                        model.LineList.Add(line = new LineElement(props));
                        line.I = jQueue.Dequeue();
                        line.J = joint;
                        line.Angle = angles[c];
                        if (c > 0)
                        {
                            model.LineList.Add(line = new LineElement(props));
                            line.I = prev;
                            line.J = joint;
                            if (c == cols - 1)
                            {
                                model.LineList.Add(line = new LineElement(props));
                                line.I = joint;
                                line.J = first;
                            }
                        }
                        prev = joint;
                    }
                }
            }
        }
AddCylinderCmd