Point Cloud – Graphing (part 2)

This article continues from the first of a 3-part segment on an example of the point cloud feature within Flowcode 6.

This week, we will implement the point cloud and creation of axis for the graph. To do so, a brief introduction to the point cloud is required. Shown below, is a quick example of how to prepare data for the point cloud.

Pic1

We have the following data points:

Data point

X

Y

Z

RGB

Value

Index

Value

Index

Value

Index

0

0

0

0

1

0

2

0xFFFFFF
1

0.2

3

0.2

4

0.2

5

0x000000
2

0.4

6

0.4

7

0.4

8

0xFF0000
3

0.6

9

0.6

10

0.6

11

0x00FF00
4

0.8

12

0.8

13

0.8

14

0x0000FF

Co-ordinates are indexed within the xyz array sequentially. If your data has an array segregated for x y and z co-ordinates in a different fashion, Flowcode makes functions available to index these arrays to this format. (see Taurus article from 2 weeks ago).

The flowcode project for this example will be attached to this article for you to evaluate.

Moving onto the previously established flowcode project, a global array to store the XYZ and RGB data is declared with 6000 elements for the xyz co-ordinates of the graphed data. Also, for the two axis of the graph, we will need extra elements for these 3 data points. These were assigned to a secondary pointcloud with handle “PCHandleaxis”. Also an RGB array is required. This is 2000 elements in size. Also an rgbaxis array is created to set the colour of the axis.

The shape on the front panel is renamed to “graphshape” to better describe its functionality. Then within the initialise macro, the handle for the graph is created as before in the example project for both the graph and the axis pointcloud.

Pic2

When simulated, we can see the X and Y axis as set in the manually entered array assignments. This pointcloud will not be referenced again as the graph will remain visible on the component indefinitely.

Within the plotgraph macro, we can begin to bring in the data passed to it by the user to the pointcloud we have created.

Pic3

The X co-ordinate is incremented from pointcloud x-co-ordinate -1, to 1 (as a proportion of the shape’s dimensions that the point cloud is created on). Going beyond -1 or 1, would place pointcloud points outside the bounds of the shape, which is not desirable.

The formula used will plot 2000 points incrementing across the x axis at varying y values. These Y values will require normalising, but this will be tackled in the final instalment of this topic.

The project file for the updated graphing component can be see attached to this article, and will be completed and simulated correctly in next week’s article.

Click here for the Flowcode files for this example: Graphing part B

4,972 total views, 1 views today

Leave a Reply