Пример #1
0
/**
 * Returns the average of the values in the list, or 0 if the list is empty.
 */
VuoReal VuoReal_average(VuoList_VuoReal values)
{
	VuoInteger count = VuoListGetCount_VuoReal(values);
	if (count == 0)
		return 0;

	VuoReal sum = 0;
	for (VuoInteger i = 1; i <= count; ++i)
		sum += VuoListGetValue_VuoReal(values, i);

	return sum/count;
}
/**
 * @file
 * vuo.type.list.real.point3d.y node implementation.
 *
 * @copyright Copyright © 2012–2015 Kosada Incorporated.
 * This code may be modified and distributed under the terms of the MIT License.
 * For more information, see http://vuo.org/license.
 */

#include "node.h"

VuoModuleMetadata({
					  "title": "Convert Real List to 3D Point List",
					  "description": "Creates a list of 3D points using the input real numbers as the Y coordinate, and 0 as the X and Z coordinates.",
					  "version": "1.0.0"
				 });

void nodeEvent
(
	VuoInputData(VuoList_VuoReal) y,
	VuoOutputData(VuoList_VuoPoint3d) point3d
)
{
	*point3d = VuoListCreate_VuoPoint3d();
	unsigned long count = VuoListGetCount_VuoReal(y);
	for (unsigned long i = 1; i <= count; ++i)
		VuoListAppendValue_VuoPoint3d(*point3d, VuoPoint3d_make(0, VuoListGetValue_VuoReal(y, i), 0));
}
#include "node.h"
#include "VuoDictionary_VuoText_VuoReal.h"

VuoModuleMetadata({
					  "title" : "Make Dictionary",
					  "keywords" : [ ],
					  "version" : "1.0.0",
					  "node": {
						  "exampleCompositions" : [ ]
					  }
				 });


void nodeEvent
(
		VuoInputData(VuoList_VuoText) keys,
		VuoInputData(VuoList_VuoReal) values,
		VuoOutputData(VuoDictionary_VuoText_VuoReal) dictionary
)
{
	*dictionary = VuoDictionaryCreate_VuoText_VuoReal();

	unsigned long count = MIN( VuoListGetCount_VuoText(keys), VuoListGetCount_VuoReal(values) );
	for (unsigned long i = 1; i <= count; ++i)
	{
		VuoText key = VuoListGetValue_VuoText(keys, i);
		VuoReal value = VuoListGetValue_VuoReal(values, i);
		VuoDictionarySetKeyValue_VuoText_VuoReal(*dictionary, key, value);
	}
}
Пример #4
0
				 });

#define DEG2RAD 0.0174532925

void nodeEvent
(
	VuoInputData(VuoLayer) layer,
	VuoInputData(VuoList_VuoPoint2d) translations,
	VuoInputData(VuoList_VuoReal) rotations,
	VuoInputData(VuoList_VuoPoint2d) scales,
	VuoOutputData(VuoList_VuoLayer) copies
)
{
	// get largest array ('cause we extrapolate if other arrays aren't equal in size to match largest)
	unsigned int 	t = VuoListGetCount_VuoPoint2d(translations), 
					r = VuoListGetCount_VuoReal(rotations),
					s = VuoListGetCount_VuoPoint2d(scales);

	unsigned int len = t;
	if(len < r || len < s) len = r > s ? r : s;

	*copies = VuoListCreate_VuoLayer();

	for(int i = 0; i < len; i++)
	{
		VuoPoint2d translation 	= VuoListGetValueAtIndex_VuoPoint2d(translations, i+1);
		VuoReal rotation 		= VuoListGetValueAtIndex_VuoReal(rotations, i+1);
		VuoPoint2d scale 		= VuoListGetValueAtIndex_VuoPoint2d(scales, i+1);

		// if i is greater than the length of array, the value will be clamped to the last item in list.  use the last item and prior to last
		// item to linearly extrapolate the next value.
						"transform", "rotation", "euler", "quaternion", "quat", "glm"
					 ],
					 "version" : "1.0.0",
					 "dependencies" : [
					 ],
					 "node": {
					 }
				 });

void nodeEvent
(
		VuoInputData(VuoList_VuoReal) matrix,
		VuoOutputData(VuoTransform) transform
)
{
	bool is4x4 = VuoListGetCount_VuoReal(matrix) == 16;
	bool is3x3 = VuoListGetCount_VuoReal(matrix) == 9;

	if(!is3x3 && !is4x4)
		return;

	VuoReal* m = VuoListGetData_VuoReal(matrix);

	float values[16];

	if(is4x4)
	{
		for(int i = 0; i < 16; i++)
			values[i] = (float) m[i];
	}
	else