Point3dcollection to mwarray

HI everybody,
I need a help!!
I'm developping code in vb.net and i need to convert a point3dcollection (like {1.2,3.4,1.5 3.4,6.7,1.3 5.5,4.3,6.7 ........}) to a mwarray.
Somebody can help me?
Thanks

Answers (1)

Hi gianluca.
To convert a Point3DCollection to an MWArray in VB.NET, you need to first extract the points from the Point3DCollection and then create an MWNumericArray using those points.
  • Extract Points from Point3DCollection: Iterate through the Point3DCollection to extract the X, Y, and Z coordinates of each point.
  • Create an MWNumericArray: Use the extracted coordinates to create an MWNumericArray object.
Kindly refer to the following function as an example:
Function ConvertToMWArray(points As Point3DCollection) As MWNumericArray
' Create a 2D array to hold the point data
Dim data(points.Count - 1, 2) As Double
' Populate the array with the point data
For i As Integer = 0 To points.Count - 1
data(i, 0) = points(i).X
data(i, 1) = points(i).Y
data(i, 2) = points(i).Z
Next
' Create an MWNumericArray from the 2D array
Dim mwArray As New MWNumericArray(data)
Return mwArray
End Function

Tags

Asked:

on 14 Jan 2022

Answered:

on 5 Feb 2025

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!