Hi, someone could tell me how I could do the dot product between vectors?
OpenSteer's Vec3 has a dot method for computing the scalar product of two Vec3s:
> a.dot(b)
I think you are talking about your "feature vectors" which may be an STL std::vector? In any case the basic idea would be something like:
> float scalarProduct = 0; > > for (int i=0; i<featureVectorLength; i++) scalarProduct += a_ * b ;
Or am I missing the point of your question?
_
Hi, the property "feature" is a Vec3 type…I must do the dot product of each vehicle with its neighbors. I created 3 groups of 10 vehicles in this way:
Agente* agenti; Agente* a_agenti; Agente* b_agenti; Agente* c_agenti;
"agenti" refers to all vehicles. Correct?
In the method I gave each group different values for the vector of "features" and then I have made every agent could do the dot product with the neighbors .. okay as I did?
***void Agente::updateFeatures(Vec3 *features)*** {
a_agenti->features.set(1,0,0); b_agenti->features.set(0,1,0); c_agenti->features.set(0,0,1);
for(int q=0; q<29; q++) { const float maxRadius = 3 * maxSpeed() * 2; neighbors.clear(); proximityToken->findNeighbors (position(), maxRadius,neighbors);
for (size_t neighborelementindex = 0; neighborelementindex < neighbors.size(); neighborelementindex++ ) { (Agente*)neighbors; Agente* aneighbor = (Agente*)neighbors;
float diff = diff + ( (agenti.features).dot(aneighbor->features) ); } } }
Log in to post a comment.
Hi, someone could tell me how I could do the dot product between vectors?
OpenSteer's Vec3 has a dot method for computing the scalar product of two Vec3s:
> a.dot(b)
I think you are talking about your "feature vectors" which may be an STL std::vector? In any case the basic idea would be something like:
> float scalarProduct = 0;
>
> for (int i=0; i<featureVectorLength; i++) scalarProduct += a_ * b ;
Or am I missing the point of your question?
_
Hi, the property "feature" is a Vec3 type…I must do the dot product of each vehicle with its neighbors.
I created 3 groups of 10 vehicles in this way:
Agente* agenti;
Agente* a_agenti;
Agente* b_agenti;
Agente* c_agenti;
"agenti" refers to all vehicles. Correct?
In the method I gave each group different values for the vector of "features" and then I have made every agent could do the dot product with the neighbors .. okay as I did?
***void Agente::updateFeatures(Vec3 *features)***
{
a_agenti->features.set(1,0,0);
b_agenti->features.set(0,1,0);
c_agenti->features.set(0,0,1);
for(int q=0; q<29; q++)
{
const float maxRadius = 3 * maxSpeed() * 2;
neighbors.clear();
proximityToken->findNeighbors (position(), maxRadius,neighbors);
for (size_t neighborelementindex = 0; neighborelementindex < neighbors.size(); neighborelementindex++ )
{
(Agente*)neighbors;
Agente* aneighbor = (Agente*)neighbors;
float diff = diff + ( (agenti.features).dot(aneighbor->features) );
}
}
}