This function returns true or false regarding the new cuboids intersects with other cuboid. I need to write new function which uses that function, and if it is false(meaning that cuboids does not intersect each other) they must be connected with each other:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
void
Poly::add(const Cuboid &cuboid, const Quaternion<float> &rotation)
{
for (Cuboid i = 0; i < number_of_cuboids(); i++)
{
auto intersection =intersecting(_cuboid[i],_rotations[i], i);
if (intersection = false) {
_cuboids = _cuboids.push_back(i);
_rotations = _rotations.push_back(i);
}
}
However I have a strong feeling that I am simplifying everything too much, and it is wrong. In general, it should check if current cuboid intersecting with any of previous, and if not, then should be added to the vector of cuboids (poly)
It doesn't seem you're using the parameters for anything.
Also, intersection = false is an assignment, not a test - the compiler should issue a warning.
Is the type Cuboid an integer? It is being used as an index to apparently the member array _cuboid. Then, too, I can't see what container _cuboid is, so I might be totally lost trying to read this.
get the logic and math and all down. Forget the object part, mostly: inside your class method, which is just a normal function with some extra qualifiers on it, the class variables are effectively globals, and in there you can just code it. Get that down and if any of the class stuff gives trouble, show us and ask, but from what we have seen the class stuff here is going to be the least of your worries.
== means 'is this equal to that'
= mean 'make this equal to that'
and the language will let you use = where you meant == (with a warning as noted above) but its a common mistake that you need to always watch for.
Hmmm...that's not a class description. That's a class constructor function. I can't, for example, see the type of _cuboids still. I can see it consumes a temporary vector that takes a Cuboid, but I still don't know what a Cuboid is, really.
Further, even if _cuboids was a vector, it doesn't return a vector for assignment to _cuboids. A push_back is typically used:
Sorry, the description is shown below. I am really sorry for such unclear question; however, so it happened that I must learn basics right from the middle of quite complex code.
in general, I need to take the i element of vector cuboid, check it against the function intersecting, if I get false, I must it add to the vector. So currently the function is:
1 2 3 4 5 6 7 8 9 10 11 12 13 14
void
Poly::add(const Cuboid &cuboid, const Quaternion<float> &rotation)
{
for (int32_t i = 0; i < number_of_cuboids(); i++)
{
auto intersection =intersecting(_cuboids[i],_rotations[i], i);
if (intersection == false) {
_cuboids.push_back(i);
_rotations.push_back(i);
}
}
I still see the warning that _cuboids.push_back(i) : no matching member function for call to 'pushback'