Geometry.GetClosestLocations operator

導入

v5.0

詳細

指定された入力位置に最も近いサーフェイスの位置を含むPointLocatorDataオブジェクトを戻します。デフォルトでは、入力位置はオブジェクトのローカル空間リファレンスに定義する必要があります。

リファレンスポーズまたはメソッドなどの最短位置計算(最も近いサーフェイス、最も近いノット/頂点など)は、Geometry.SetupPointLocatorQueriesを使用してセットアップできる場合があります。このセットアップは以降に呼び出すすべてのGetClosestLocationsおよびGeometry.GetClosestLocationsWithinRadiusに影響します。

このメソッドを呼び出すと、高速化用のキャッシュが自動的に作成されます。詳細については、Geometry.SetupPointLocatorQueries を参照してください。

「最短距離」のリレーションシップは、ジオメトリおよび入力位置の空間基準に対して相対的に変化します。詳細については、Geometry.SetupPointLocatorQueries を参照してください。

同じトポロジを持つ任意の Geometry インスタンスについてポイントロケータが計算され、戻される場合があります。

C#構文

PointLocatorData Geometry.GetClosestLocations( Object in_pPositions );

スクリプト構文

oReturn = Geometry.GetClosestLocations( Positions );

戻り値

PointLocatorData

パラメータ

パラメータ タイプ 説明
Positions Array パックされたXYZトリプレットの 1D 配列または XYZトリプレットの 2D 配列のいずれかの書式のDouble配列。

1. JScript の例

/*

	Example using PointLocatorData to find the closest mesh sphere vertex from a Null

*/

NewScene();

var NullObj = GetPrim("Null", null, null, null);

Translate(NullObj, -2.0, 8.0, 5.0, siRelative, siView, siObj, siXYZ);

var SphereGeom = CreatePrim("Sphere", "MeshSurface").ActivePrimitive.Geometry;

var ClosestPointLocator = SphereGeom.GetClosestLocations(NullObj.Kinematics.Global.Transform.GetTranslationValues2());

var ClosestPosition = SphereGeom.EvaluatePositions(ClosestPointLocator).toArray();

var TriangleVertices = SphereGeom.GetTriangleVertexIndexArray(ClosestPointLocator).toArray();

var TriangleWeights = SphereGeom.GetTriangleWeightArray(ClosestPointLocator).toArray();

Application.LogMessage("The closest position on the mesh sphere from the Null is ("

	+ ClosestPosition[0] + ", " + ClosestPosition[1] + ", " + ClosestPosition[2] + ")");

Application.LogMessage("which corresponds to the triangle made of vertices ("

	+ TriangleVertices[0] + ", " + TriangleVertices[1] + ", " + TriangleVertices[2] + ").");

Application.LogMessage("The barycentric weight relatively to each triangle vertex is ("

	+ TriangleWeights[0] + ", " + TriangleWeights[1] + ", " + TriangleWeights[2] + ").");

//INFO : The closest position on the mesh sphere from the Null is (-0.6959691047668459, 3.2883720624894605, 1.8517908803876053)

//INFO : which corresponds to the triangle made of vertices (14, 21, 22).

//INFO : The barycentric weight relatively to each triangle vertex is (0.34798455238342285, 0.12156937271356582, 0.5304460525512695).

2. JScript の例

/*

	This example uses PointLocatorData to shrink-wrap a sphere to a cube,

	and then push the sphere along the cube's normals.

*/

NewScene(null, false);

var root = Application.ActiveSceneRoot;

var CubeGeom = root.AddGeometry("Cube", "MeshSurface").ActivePrimitive.Geometry;

var SphereObj = root.AddGeometry("Sphere", "MeshSurface");

SphereObj.subdivv = 24;

SphereObj.subdivu = 24;

// We must freeze it, otherwise its position array cannot be set:

FreezeObj(SphereObj);

var SphereGeom = SphereObj.ActivePrimitive.Geometry;

var SphereOnCubePointLocators = CubeGeom.GetClosestLocations(SphereGeom.Points.PositionArray);

var SphereOnCubePositions = CubeGeom.EvaluatePositions(SphereOnCubePointLocators).toArray();

var SphereOnCubeNormals = CubeGeom.EvaluateNormals(SphereOnCubePointLocators).toArray();

for (i = 0; i < SphereOnCubePositions.length; i++)

	SphereOnCubePositions[i] += SphereOnCubeNormals[i]*3;

SphereGeom.Points.PositionArray = SphereOnCubePositions;

関連項目

PointLocatorData Geometry Geometry.GetClosestLocationsWithinRadius Geometry.GetRaycastIntersections Geometry.SetupPointLocatorQueries Geometry.GetSurfacePointLocatorsFromPoints Geometry.EvaluatePositions Geometry.EvaluateNormals Geometry.EvaluateClusterProperty PolygonMesh.GetPolygonIndexArray PolygonMesh.GetTriangleVertexIndexArray PolygonMesh.GetTriangleNodeIndexArray PolygonMesh.GetTriangleWeightArray PolygonMesh.ConstructPointLocators NurbsSurfaceMesh.GetSubSurfaceIndexArray NurbsSurfaceMesh.GetNormalizedUVArray NurbsSurfaceMesh.ConstructPointLocators