I have a very weird problem. Recently i am developing my own namespace of classes in C# with vector fields,pheromones, boids slime mould etc. I have class with VectorPheromoneField (contains 2d or 3d grid, built with arrays, with VectorPheromonePoint class - containing position, vector and int value). Agent class contains function to search a closest point in field grid, project searching points in front of it etc. Basically a Slime Mould logic but opened to experimentation.
While searching for info in the web, i came across and idea to project a 2D grid on surface UVs. I have tried to implement it, but i came across this weird effect:
White cloud points are outputted from VectorField (color and alpha is pheromone int value) and red dots are agents. In every other VectorField that i scripted without projection on surface agents where directly following pheromones traces, which is obviously logical. But here agents seem to be somehow flipped, even if the pheromone pattern is built properly (exeactly like it would be with a VectorField 2d grid not on surface).
I am decent in scripting points, vectors etc but a bit of a newbie in NURBS. What may be the reason?
-grid is based on a function that i wrote SurfaceDivide (grid [,]) which outputs PointAt from surface using reparametrised domain
-agent searches for strognest pheromone point using three vectors in front of it, two rotated and one frontal, and finds a pheromone point from 2d grid closest to the projected vector
-then agent is moved accordingly and projected on surface using ClosestPoint and PointAt.
What may i have done wrong?