algorithmic modeling for Rhino
I am newbie in C#. I made GH definition for sphere point creation - it's works perfect ,and trying to make same C# component - it not works at all. Can somebody help me with it ? Problems with formula that generates "fresult" list (line: f = Math.Acos(-1 + (2 * loop - 1) / x) ). Thanks for help.
double f,t,k,g,b;
List<Point3d> pts = new List<Point3d>();
List<double> fresult = new List<double>();
for(int loop = 1;loop <= x;loop++){
f = Math.Acos(-1 + (2 * loop - 1) / x);
t = Math.Sqrt(x * Math.PI) * f;
k = y * Math.Sin(f) * Math.Cos(t);
g = y * Math.Cos(f) * Math.Sin(t);
b = y * Math.Cos(f);
Point3d temp = new Point3d(k, g, b);
pts.Add(temp);
fresult.Add(f);
}
A = pts;
fResult = fresult;
Tags:
In C#, when you divide two integers, you get an integer in return. I.e. this:
-1 + (2 * loop - 1) / x
Is computed in integer accuracy. You should specifically convert one of the division parts into doubles:
-1 + (2 * loop - 1) / (double)x
--
David Rutten
david@mcneel.com
Welcome to
Grasshopper
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
© 2024 Created by Scott Davidson. Powered by