// create a CoordinateSystem at a specific location,
// no rotations, scaling, or sheering transformations
x_pos = 3.6;
y_pos = 9.4;
z_pos = 13.0;
origin = Point.ByCoordinates(x_pos, y_pos, z_pos);
identity = CoordinateSystem.Identity();
cs = CoordinateSystem.ByOriginVectors(origin,
identity.XAxis, identity.YAxis, identity.ZAxis);
点
最简单的几何基本体是一个点,表示三维空间中的零维位置。如前所述,可以通过几种不同的方式在特定坐标系中创建点:Point.ByCoordinates 使用指定的 x、y 和 z 坐标创建点;Point.ByCartesianCoordinates 使用指定的 x、y 和 z 坐标在特定坐标系中创建点;Point.ByCylindricalCoordinates 使用半径、旋转角度和高度创建位于圆柱体上的点;Point.BySphericalCoordinates 使用半径和两个旋转角度创建位于球体上的点。
本例说明在各种坐标系中创建的点:
// create a point with x, y, and z coordinates
x_pos = 1;
y_pos = 2;
z_pos = 3;
pCoord = Point.ByCoordinates(x_pos, y_pos, z_pos);
// create a point in a specific coordinate system
cs = CoordinateSystem.Identity();
pCoordSystem = Point.ByCartesianCoordinates(cs, x_pos,
y_pos, z_pos);
// create a point on a cylinder with the following
// radius and height
radius = 5;
height = 15;
theta = 75.5;
pCyl = Point.ByCylindricalCoordinates(cs, radius, theta,
height);
// create a point on a sphere with radius and two angles
phi = 120.3;
pSphere = Point.BySphericalCoordinates(cs, radius,
theta, phi);
线
下一个较高维度的 Dynamo 基本体是一条线段,表示两个端点之间的无限多个点。可以通过构造函数 Line.ByStartPointEndPoint 明确指定两个边界点,或者通过 Line.ByStartPointDirectionLength 在该方向指定起点、方向和长度来创建直线。
p1 = Point.ByCoordinates(-2, -5, -10);
p2 = Point.ByCoordinates(6, 8, 10);
// a line segment between two points
l2pts = Line.ByStartPointEndPoint(p1, p2);
// a line segment at p1 in direction 1, 1, 1 with
// length 10
lDir = Line.ByStartPointDirectionLength(p1,
Vector.ByCoordinates(1, 1, 1), 10);