Vector3 math in C#/VVVV plugins

Hi there,

i’m currently working in vvvv’s code editor. I’d like to do some Vector3 math operations. But i’m stuck.

I would like to set one input pin as a three dimensional vector (Vec3) to input a spread from a Vector (3d Join) node to declare it as

[Input("Spread Vec3", DefaultValue = 1.0)](Input("Spread Vec3", DefaultValue = 1.0))
		public ISpread<double> FVec3Spread;

In the next step I’d like to adress the x, y, z from this Vec3 via

for (int i = 0; i < SpreadMax; i++)
FVec3Spread.x[i](i) = ...;
FVec3Spread.y[i](i) = ...;				
FVec3Spread.z[i](i) = ...;

But I don’t know how to get the input spread as Vector3 nor how to set is as a variable.

I already consulted pluginspecs/ but i’m not able to abstract what i read.

Can anyone help, please?




you can just write:

public ISpread<Vector3D> FVec3SpreadIn;

public ISpread<Vector3D> FVec3SpreadOut;

and then access and process it like:

for (int i = 0; i < SpreadMax; i++)
var vectorSliceFromInputPin = FVec3SpreadIn[i](i);
//do some math
FVec3SpreadOut[i](i) = resultVectorFromCalculation;

the plugin interface does all the type conversion and slice handling for you. if you want to set the default value of the input you need to write:

[Input("Input", DefaultValues = new double[](Input("Input", DefaultValues = new double[){1.0, 0.0, 0.0})]
public ISpread<Vector3D> FVec3SpreadIn;


In general, have a look at some example code within the vvvv-sdk:

It’s helpful for learning purposes, to see how others get the job done.

In your specific case you’d want to go with ISpread.