Example Code

Order Points for Centroid Calculation in LabVIEW

Products and Environment

This section reflects the products and operating system used to create the example.

To download NI software, including the products shown below, visit ni.com/downloads.

    Software

  • LabVIEW

Code and Documents

Attachment

Description

When you input point data randomly, Centroid VI returns invalid value such as NaN.

For example:

X: -1 -1 1 1

Y: -1 1 -1 1

-> (NaN, NaN)

photo.jpg

 

You need to order the points not to cross the diagram such as:

X: -1 -1 1 1

Y: -1 1 1 -1

->(0, 0)

 

To establish this, there may be many ways. I would like to show one example how to order the points.

I searched the left edge of the points and calculate angles between vectors and order the points by the angles.

 

photo.jpg

Related Links

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.

Contributors