We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hi
What is the best way to return <Int, Float, Float> values from a method using an array? I am trying to make a fiducial class which detects the x and y location of the fiducials identified using an ID.
I am new to processing and trying to get a hang of it. Thanks in advance.
Regards
S
Answers
Don't use an array. Create a class that contains these values and return an instance of that instead.
You could also use an array of Numbers.
Java got 8 primitive types. And unfortunately, if we need to return all of those primitive types, we have to create a function for each of them: #:-S
http://docs.Oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html
As mentioned, create a class to encapsulate those 3 values w/ diff. datatypes: *-:)
Hi
Thanks guys. For now i am taking a simpler approach. Here is the code.
Thanks
S
Glad you found a solution that works for you.
If you are trying to return 2 or 3 float values that relate to xyz coordinates or offsets (e.g. your
float[] xy
), an easy way is creating and returning a PVector object, then accessing the x y z properties. PVector is idiomatic to Processing and the class comes with a number of convenience methods.