Matlab geom3d函数注释
Matlab geom3d函数解析
geom3d函数库
geom3d库的目的是处理和可视化三维几何原语,如点、线、平面、多面体等。它提供了操作三维几何原语的底层功能,使得开发更复杂的几何算法变得更加容易。
序号 | 函数名 | 作用 | 输入 | 输出 |
---|---|---|---|---|
1 | area = triangleArea3d(pt1, pt2, pt3) |
获取三角形面积 | 三个点坐标 [10 10 10], [30 10 10], [10 40 10] | 面积 |
2 | area = polygonArea3d(poly, varargin) |
获取三维多边形的面积 | 点的坐标向量poly = [10 30 20;20 30 20;20 40 20;10 40 20] | 面积 |
3 | centroid = polygonCentroid3d(varargin) |
获取三维多边形的中点 | 点坐标 poly = [0 0 0; 10 0 10;10 10 20;0 10 10] | 点坐标 |
4 | point = projPointOnPlane(point, plane) |
点在平面上的正交投影 | 点坐标[ x,y,z]和平面点、两个向量 [X0 Y0 Z0 VX1 VY1 VZ1 VX2 VY2 VZ2] | 点坐标 |
5 | [newLine, isOrthogonal] = projLineOnPlane(line, plane) |
直线在平面上的投影 | 输入为线和平面 | 是否正交 |
6 | point = projPointOnLine3d(point, line) |
点在线上的投影 | 输入为点和线 | 输出为点坐标 |
7 | n = planeNormal(plane) |
计算平面的法向量 | PLANE : [x0 y0 z0 dx1 dy1 dz1 dx2 dy2 dz2] | N : [dx dy dz] |
8 | b = isPointOnLine3d(point, line, varargin) |
** 判断点是否在直线上** | point 和 line | |
9 | varargout = angleSort3d(pts, varargin) |
根据共面点在平面上的角度对其进行排序。 | ||
10 | box = boundingBox3d(points) |
点集的包围盒 | 点集 | [xmin xmax ymin ymax zmin zmax] |
11 | vol = box3dVolume(box) |
三维包围盒的体积 | ||
12 | point = circle3dPoint(circle, pos) |
点在三维圆上的坐标 | ||
13 | theta = circle3dPosition(point, circle) |
三维点在三维圆上的角度 | ||
14 | poly2 = clipConvexPolygon3dHP(poly, plane) |
用半空间裁剪一个三维的多边形 | 多边形和平面 | 输出为点集 |
15 | clipped = clipEdge3d(edge, box) |
用长方体修剪三维边 | ||
16 | edge = clipLine3d(line, box) |
用长方体修剪三维线 | 线和长方体 | 返回边 |
17 | poly2 = clipPolygon3dHP(poly, plane) |
用平面来裁剪三维多边形 | ||
18 | createEdge3d |
创建一个三维的两点之间的线 | 两个点 | 边 |
19 | createLine3d |
创建线 | 两个点 | 线 |
20 | plane = createPlane(varargin) |
创建平面 | 输入为三个点 | 平面 |
21 | mat = createRotation3dLineAngle(line, theta) |
围绕一个线旋转一定的角度 | line 和角度 | 矩阵 |
22 | trans = createScaling3d(varargin) |
创建一个4X4的缩放矩阵 | ||
23 | trans = createTranslation3d(varargin) |
创建一个4X4的平移矩阵 | ||
24 | createRotationOx |
|||
25 | createRotationOy |
|||
26 | createRotationOz |
|||
27 | ROT = createRotationVector3d(A,B) |
计算两个向量 之间的旋转 | ||
28 | TFM = createRotationVectorPoint3d(A,B,P) |
|||
29 | c = crossProduct3d(a,b) |
叉乘 | ||
30 | varargout = cyl2cart(varargin) |
柱坐标转换成笛卡尔坐标系 | ||
31 | Surface area of a cylinder. |
圆柱的表面积 | ||
32 | theta = dihedralAngle(plane1, plane2) |
计算两个面之间的二面角 | ||
33 | [d, pt1, pt2] = distanceLines3d(line1, line2) |
计算两条线之间的距离 | ||
34 | [dist, t] = distancePointEdge3d(point, edge) |
计算点到线的距离 | ||
35 | d = distancePointLine3d(point, line) |
计算点到线的距离 | ||
36 | d = distancePointPlane(point, plane) |
计算点到面的距离 | ||
37 | dist = distancePoints3d(p1, p2, varargin) |
两个点之间的距离 | ||
38 | [dist, proj] = distancePointTriangle3d(point, triangle) |
点与三角形之间的最短距离 | ||
39 | drawAxis3d(varargin) |
画一个彩色的坐标系和远点,图标 | ||
40 | varargout = drawEdge3d(varargin) |
绘制边 | ||
41 | drawBox3d |
绘制一个三维的立方盒子 | ||
42 | varargout = drawCircle3d(varargin) |
绘制一个三维的圆 | ||
43 | varargout = drawCircleArc3d(arc, varargin) |
绘制一个圆弧 | ||
44 | varargout = drawCube(cube, varargin) |
绘制一个三维的立方体,最后旋转 | ||
45 | varargout = drawCuboid(cuboid, varargin) |
绘制三维的长方体 | ||
46 | varargout = drawCylinder(cyl, varargin) |
|||
47 | varargout = drawEllipse3d(varargin) |
绘制三维椭圆 | ||
48 | varargout = drawEllipseCylinder(cyl, varargin) |
|||
49 | varargout = drawEllipsoid(elli, varargin) |
绘制椭球体 | ||
50 | varargout = drawGrid3d(varargin) |
绘制3D网格 | ||
51 | varargout = drawLabels3d(varargin) |
指定3D位置绘制标签 | ||
52 | drawPlane3d(plane, varargin) |
绘制被当前坐标系裁剪的平面 | ||
53 | varargout = drawPlatform(plane, siz, varargin) |
画一个给定尺寸的矩形平台 | ||
54 | h = drawPoint3d(varargin) |
绘制三维点 | ||
55 | varargout = drawPolygon3d(varargin) |
绘制由顶点坐标列表指定的三维多边形 | ||
56 | varargout = drawPolyline3d(varargin) |
绘制由顶点坐标列表指定的三维折线。 | ||
57 | varargout = drawSphere(varargin) |
画一个球体的网格 | ||
58 | varargout = drawSphericalEdge(sphere, edge, varargin) |
在球面上画一条边 | ||
59 | varargout = drawSphericalPolygon(sphere, poly, varargin) |
画一个球面多边形 | ||
60 | len = edgeLength3d(edge, varargin) |
三维边的长度 | ||
61 | line = edgeToLine3d(edge) |
将三维边转换成线 | ||
62 | s = ellipsoidSurfaceArea(elli) |
球体的表面积 | ||
63 | ell = equivalentEllipsoid(points) |
三维点集的等效椭球面 | ||
64 | mat = eulerAnglesToRotation3d(phi, theta, psi, varargin) |
将三维欧拉角转换为三维旋转矩阵 | ||
65 | varargout = fillPolygon3d(varargin) |
填充由顶点坐标列表指定的3D多边形 | ||
66 | varargout = fillSphericalPolygon(sphere, poly, germ) |
填充一个球面多边形 | ||
67 | varargout = fillSphericalTriangle(sphere, p1, p2, p3, varargin) |
在球体上填充一个三角形 | ||
68 | trans = fitAffineTransform3d(pts1, pts2) |
使用两个点集拟合仿射变换 | ||
69 | [fittedCircle, circleNormal] = fitCircle3d(pts) |
拟合圆 | ||
70 | fitEllipse3d |
|||
71 | fitLine3d |
|||
72 | fitPlane |
|||
73 | h = hypot3(dx, dy, dz) |
三维包围盒的对角线长度 | ||
74 | box = intersectBoxes3d(box1, box2) |
三维盒子的交集 | ||
75 | point = intersectEdgePlane(edge, plane, varargin) |
边和面的交点 | ||
76 | points = intersectLineCylinder(line, cylinder, varargin) |
线和圆柱的交点 | ||
77 | point = intersectLinePlane(line, plane, varargin) |
线和面的交点 | ||
78 | [inter, inside]= intersectLinePolygon3d(line, poly) |
直线与三维多边形的交点 | ||
79 | points = intersectLineSphere(line, sphere, varargin) |
|||
80 | [point, pos, isInside] = intersectLineTriangle3d(line, triangle, varargin) |
三维直线和三维三角形的交点 | ||
81 | line = intersectPlanes(plane1, plane2, varargin) |
面和面的交线 | ||
82 | circle = intersectPlaneSphere(plane, sphere) |
平面与球面的交点圆 | ||
83 | [inter, inside]= intersectRayPolygon3d(ray, poly) |
三维射线与三维多边形的交点 | ||
84 | point = intersectThreePlanes(plane1, plane2, plane3) |
三个面的交点 | ||
85 | below = isBelowPlane(point, varargin) |
测试一个点在平面上还是平面下 | ||
86 | copl = isCoplanar(x,y,z,tol) |
测试输入点的共面性 | ||
87 | b = isParallel3d(v1, v2, varargin) |
判断向量是否平行 | ||
88 | b = isPerpendicular3d(v1, v2, varargin) |
判断向量的正交性 | ||
89 | d = isPlane(plane) |
判断是否为面 | ||
90 | a = isTransform3d(trans, varargin) |
判断是否为变换矩阵 | ||
91 | pos = linePosition3d(point, line) |
返回投影在3D直线上的3D点的位置 | ||
92 | edge = lineToEdge3d(line) |
将直线转化成边 | ||
93 | plane = medianPlane(p1, p2) |
两点中间的平面 | ||
94 | box = mergeBoxes3d(box1, box2) |
合并3D盒,通过计算他们的最大范围 | ||
95 | varargout = midPoint3d(varargin) |
两个三维点的中点或三维边的中点 | ||
96 | plane2 = normalizePlane(plane1) |
将平面的参数表示标准化 | ||
97 | vn = normalizeVector3d(v) |
向量标准化 | ||
98 | S = oblateSurfaceArea(elli, varargin) |
近似扁椭球的表面积 | ||
99 | box3d = orientedBox3d(pts) |
带朝向的包围盒 | ||
100 | res = parallelLine3d(line, point) |
创建平行的直线 | ||
101 | res = parallelPlane(plane, point) |
创建平行面 | ||
102 | n = planeNormal(plane) |
计算平面的法向量 | ||
103 | coord = planePoint(plane, point) |
计算平面上点的三维位置 | ||
104 | coord = planePoint(plane, point) |
计算平面上点的三维位置-- | ||
105 | pos = planePosition(point, plane) |
计算点在平面上的位置-- | ||
106 | out = planesBisector(plane1, plane2) |
两个其它平面之间的平分线平面 | ||
107 | theta = polygon3dNormalAngle(points, ind) |
三维多边形顶点的法向角 |
全部函数简介
% GEOM3D Geometry 3D Toolbox
% Version 1.22 06-Jun-2018 .
%
% Creation, transformations, algorithms and visualization of geometrical
% 3D primitives, such as points, lines, planes, polyhedra, circles and
% spheres.
%
% Euler Angles are defined as follow:
% PHI is the azimut, i.e. the angle of the projection on horizontal plane
% with the Ox axis, with value beween 0 and 180 degrees.
% THETA is the latitude, i.e. the angle with the Oz axis, with value
% between -90 and +90 degrees.
% PSI is the 'roll', i.e. the rotation around the (PHI, THETA) direction,
% with value in degrees
% See also the 'angles3d' page.
%
% Base format for primitives:
% Point: [x0 y0 z0]
% Vector: [dx dy dz]
% Line: [x0 y0 z0 dx dy dz]
% Edge: [x1 y1 z1 x2 y2 z2]
% Plane: [x0 y0 z0 dx1 dy1 dz1 dx2 dy2 dz2]
% Sphere: [x0 y0 z0 R]
% Circle: [x0 y0 z0 R PHI THETA PSI] (origin+center+normal+'roll').
% Ellipsoid: [x0 y0 z0 A B C PHI THETA PSI]
% Cylinder: [X1 Y1 Z1 X2 Y2 Z2 R]
% Box: [xmin xmax ymin ymax zmin zmax]. Used for clipping shapes.
%
% Polygons are represented by N-by-3 array of points, the last point is
% not necessarily the same as the first one. Points must be coplanar.
%
%
% 3D Points
% points3d - Description of functions operating on 3D points.
% midPoint3d - Middle point of two 3D points or of a 3D edge.
% isCoplanar - Tests input points for coplanarity in 3-space.
% transformPoint3d - Transform a point with a 3D affine transform.
% distancePoints3d - Compute euclidean distance between pairs of 3D Points.
% clipPoints3d - Clip a set of points by a box or other 3d shapes.
% drawPoint3d - Draw 3D point on the current axis.
%
% 3D Vectors
% vectors3d - Description of functions operating on 3D vectors.
% transformVector3d - Transform a vector with a 3D affine transform.
% normalizeVector3d - Normalize a 3D vector to have norm equal to 1.
% vectorNorm3d - Norm of a 3D vector or of set of 3D vectors.
% hypot3 - Diagonal length of a cuboidal 3D box .
% crossProduct3d - Vector cross product faster than inbuilt MATLAB cross.
% vectorAngle3d - Angle between two 3D vectors.
% isParallel3d - Check parallelism of two 3D vectors.
% isPerpendicular3d - Check orthogonality of two 3D vectors.
% drawVector3d - Draw vector at a given position.
%
% Angles
% angles3d - Conventions for manipulating angles in 3D.
% anglePoints3d - Compute angle between three 3D points.
% sphericalAngle - Compute angle between points on the sphere.
% angleSort3d - Sort 3D coplanar points according to their angles in plane.
% randomAngle3d - Return a 3D angle uniformly distributed on unit sphere.
%
% Coordinate transforms
% sph2cart2 - Convert spherical coordinates to cartesian coordinates.
% cart2sph2 - Convert cartesian coordinates to spherical coordinates.
% cart2sph2d - Convert cartesian coordinates to spherical coordinates in degrees.
% sph2cart2d - Convert spherical coordinates to cartesian coordinates in degrees.
% cart2cyl - Convert cartesian to cylindrical coordinates.
% cyl2cart - Convert cylindrical to cartesian coordinates.
%
% 3D Lines and Edges
% lines3d - Description of functions operating on 3D lines.
% edges3d - Description of functions operating on 3D edges.
% createLine3d - Create a line with various inputs.
% createEdge3d - Create an edge between two 3D points, or from a 3D line.
% fitLine3d - Fit a 3D line to a set of points.
% parallelLine3d - Create 3D line parallel to another one.
% projPointOnLine3d - Project a 3D point orthogonally onto a 3D line.
% distancePointLine3d - Euclidean distance between 3D point and line.
% isPointOnLine3d - Test if a 3D point belongs to a 3D line.
% distancePointEdge3d - Minimum distance between a 3D point and a 3D edge.
% linePosition3d - Return the position of a 3D point projected on a 3D line.
% distanceLines3d - Minimal distance between two 3D lines.
% transformLine3d - Transform a 3D line with a 3D affine transform.
% reverseLine3d - Return same 3D line but with opposite orientation.
% midPoint3d - Middle point of two 3D points or of a 3D edge.
% edgeLength3d - Return the length of a 3D edge.
% clipEdge3d - Clip a 3D edge with a cuboid box.
% lineToEdge3d - Convert a 3D straight line to a 3D finite edge.
% edgeToLine3d - Convert a 3D edge to a 3D straight line.
% clipLine3d - Clip a line with a box and return an edge.
% drawEdge3d - Draw 3D edge in the current axes.
% drawLine3d - Draw a 3D line clipped by the current axes.
%
% Planes
% planes3d - Description of functions operating on 3D planes.
% createPlane - Create a plane in parametrized form.
% fitPlane - Fit a 3D plane to a set of points.
% normalizePlane - Normalize parametric representation of a plane.
% parallelPlane - Parallel to a plane through a point or at a given distance.
% reversePlane - Return same 3D plane but with opposite orientation.
% isPlane - Check if input is a plane.
% transformPlane3d - Transform a 3D plane with a 3D affine transform.
% planesBisector - Bisector plane between two other planes.
% projPointOnPlane - Return the orthogonal projection of a point on a plane.
% intersectPlanes - Return intersection line between 2 planes in space.
% intersectThreePlanes - Return intersection point between 3 planes in space.
% intersectLinePlane - Intersection point between a 3D line and a plane.
% intersectEdgePlane - Return intersection point between a plane and a edge.
% distancePointPlane - Signed distance betwen 3D point and plane.
% projLineOnPlane - Return the orthogonal projection of a line on a plane.
% isBelowPlane - Test whether a point is below or above a plane.
% medianPlane - Create a plane in the middle of 2 points.
% planeNormal - Compute the normal to a plane.
% planePosition - Compute position of a point on a plane.
% planePoint - Compute 3D position of a point in a plane.
% dihedralAngle - Compute dihedral angle between 2 planes.
% drawPlane3d - Draw a plane clipped by the current axes.
%
% 3D Polygons and curves
% polygons3d - Description of functions operating on 3D polygons.
% polygonCentroid3d - Centroid (or center of mass) of a polygon.
% polygonArea3d - Area of a 3D polygon.
% polygon3dNormalAngle - Normal angle at a vertex of the 3D polygon.
% intersectLinePolygon3d - Intersection point of a 3D line and a 3D polygon.
% intersectRayPolygon3d - Intersection point of a 3D ray and a 3D polygon.
% clipConvexPolygon3dHP - Clip a convex 3D polygon with Half-space.
% drawPolygon3d - Draw a 3D polygon specified by a list of vertex coords.
% drawPolyline3d - Draw a 3D polyline specified by a list of vertex coords.
% fillPolygon3d - Fill a 3D polygon specified by a list of vertex coords.
%
% 3D Triangles
% triangleArea3d - Area of a 3D triangle.
% distancePointTriangle3d - Minimum distance between a 3D point and a 3D triangle.
% intersectLineTriangle3d - Intersection point of a 3D line and a 3D triangle.
%
% 3D circles and ellipses
% circles3d - Description of functions operating on 3D circles.
% fitCircle3d - Fit a 3D circle to a set of points.
% circle3dPosition - Return the angular position of a point on a 3D circle.
% circle3dPoint - Coordinates of a point on a 3D circle from its position.
% circle3dOrigin - Return the first point of a 3D circle.
% drawCircle3d - Draw a 3D circle.
% drawCircleArc3d - Draw a 3D circle arc.
% drawEllipse3d - Draw a 3D ellipse.
%
% Spheres
% spheres - Description of functions operating on 3D spheres.
% createSphere - Create a sphere containing 4 points.
% intersectLineSphere - Return intersection points between a line and a sphere.
% intersectPlaneSphere - Return intersection circle between a plane and a sphere.
% drawSphere - Draw a sphere as a mesh.
% drawSphericalEdge - Draw an edge on the surface of a sphere.
% drawSphericalTriangle - Draw a triangle on a sphere.
% fillSphericalTriangle - Fill a triangle on a sphere.
% drawSphericalPolygon - Draw a spherical polygon.
% fillSphericalPolygon - Fill a spherical polygon.
% sphericalVoronoiDomain - Compute a spherical voronoi domain.
%
% Smooth surfaces
% equivalentEllipsoid - Equivalent ellipsoid of a set of 3D points.
% fitEllipse3d - Fit an ellipse to a set of points.
% ellipsoidSurfaceArea - Approximated surface area of an ellipsoid.
% oblateSurfaceArea - Approximated surface area of an oblate ellipsoid.
% prolateSurfaceArea - Approximated surface area of a prolate ellipsoid.
% cylinderSurfaceArea - Surface area of a cylinder.
% intersectLineCylinder - Compute intersection points between a line and a cylinder.
% revolutionSurface - Create a surface of revolution from a planar curve.
% surfaceCurvature - Curvature on a surface from angle and principal curvatures.
% drawEllipsoid - Draw a 3D ellipsoid.
% drawTorus - Draw a torus (3D ring).
% drawCylinder - Draw a cylinder.
% drawEllipseCylinder - Draw a cylinder with ellipse cross-section.
% drawSurfPatch - Draw a 3D surface patch, with 2 parametrized surfaces.
%
% Bounding boxes management
% boxes3d - Description of functions operating on 3D boxes.
% boundingBox3d - Bounding box of a set of 3D points.
% orientedBox3d - Object-oriented bounding box of a set of 3D points.
% intersectBoxes3d - Intersection of two 3D bounding boxes.
% mergeBoxes3d - Merge 3D boxes, by computing their greatest extent.
% box3dVolume - Volume of a 3-dimensional box.
% randomPointInBox3d - Generate random point(s) within a 3D box.
% drawBox3d - Draw a 3D box defined by coordinate extents.
%
% Geometric transforms
% transforms3d - Conventions for manipulating 3D affine transforms.
% fitAffineTransform3d - Fit an affine transform using two point sets.
% registerPoints3dAffine - Fit 3D affine transform using iterative algorithm.
% createTranslation3d - Create the 4x4 matrix of a 3D translation.
% createScaling3d - Create the 4x4 matrix of a 3D scaling.
% createRotationOx - Create the 4x4 matrix of a 3D rotation around x-axis.
% createRotationOy - Create the 4x4 matrix of a 3D rotation around y-axis.
% createRotationOz - Create the 4x4 matrix of a 3D rotation around z-axis.
% createBasisTransform3d - Compute matrix for transforming a basis into another basis.
% eulerAnglesToRotation3d - Convert 3D Euler angles to 3D rotation matrix.
% isTransform3d - Check if input is a affine transformation matrix.
% rotation3dToEulerAngles - Extract Euler angles from a rotation matrix.
% createRotation3dLineAngle - Create rotation around a line by an angle theta.
% rotation3dAxisAndAngle - Determine axis and angle of a 3D rotation matrix.
% createRotationVector3d - Calculates the rotation between two vectors.
% createRotationVectorPoint3d - Calculates the rotation between two vectors.
% recenterTransform3d - Change the fixed point of an affine 3D transform.
% composeTransforms3d - Concatenate several space transformations.
%
% Various drawing Functions
% drawGrid3d - Draw a 3D grid on the current axis.
% drawAxis3d - Draw a coordinate system and an origin.
% drawAxisCube - Draw a colored cube representing axis orientation.
% drawCube - Draw a 3D centered cube, eventually rotated.
% drawCuboid - Draw a 3D cuboid, eventually rotated.
% drawPlatform - Draw a rectangular platform with a given size.
% drawLabels3d - Draw text labels at specified 3D positions.
%
%
% Credits:
% * Several functions contributed by Sven Holcombe
% * function isCoplanar was originally written by Brett Shoelson.
% * Songbai Ji enhanced file intersectPlaneLine (6/23/2006).
% * several functions contributed by oqilipo
%
% ------
% Author: David Legland
% e-mail: david.legland@inra.fr
% Created: 2005-11-07
% Homepage: http://github.com/mattools/matGeom
% http://www.pfl-cepia.inra.fr/index.php?page=geom3d
% Copyright 2005 INRA
% In development:
% clipPolygon3dHP - clip a 3D polygon with Half-space.
% drawPartialPatch - draw surface patch, with 2 parametrized surfaces.
% Deprecated:
% vectorCross3d - Vector cross product faster than inbuilt MATLAB cross.
% inertiaEllipsoid - Inertia ellipsoid of a set of 3D points.
% Others