Created
February 28, 2023 09:41
-
-
Save jhorikawa/3e4065860d21838f4732b05928275059 to your computer and use it in GitHub Desktop.
C# code for Grasshopper to divide surface with angle parameter.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void RunScript(double ang, ref object A) | |
{ | |
double dang = ang * Math.PI / 180.0; | |
int div1 = (int) Math.Round(Math.PI / dang); | |
List<Point3d> points = new List<Point3d>(); | |
for(int i = 0; i < div1; i++){ | |
var a = i * Math.PI / (div1 - 1.0); | |
var cz = Math.Cos(a); | |
var cx = Math.Sin(a); | |
var dia = cx * 2.0 * Math.PI; | |
int div2 = (int) Math.Max(Math.Round(dia / dang), 1); | |
for(int n = 0; n < div2; n++){ | |
var tx = cx * Math.Cos(n * (Math.PI * 2.0 / div2)); | |
var ty = cx * Math.Sin(n * (Math.PI * 2.0 / div2)); | |
var point = new Point3d(tx, ty, cz); | |
points.Add(point); | |
} | |
} | |
A = points; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment