c++ - QGraphicsScene, how to place items based on center point -


i have qgraphicsscene, , have determined center point is, need figure out how place items in scene based on information.

i have 2 pieces of data need work with: range , bearing.

range how far away center point (or location), , bearing direction center point, 0 being north, 180 being south , on.

so example, if need place item @ range: 20, bearing: 90, item 20 (units) directly right of center point. currently, placing item data based off 0,0 being top left of scene.

this needs able scale zoom state of qgraphicsscene well.

i'm totally lost @ conversion.

unsure of how proper offsets converting coordinate system coordinate system managed find solution. it's not considered of hack job.

first needed offset top left (0,0), , knowing scene 360, 360 easy.

not being math guy unsure getting angles, after research saw info had needed derive vector.

here method wrote me generate items in qgraphicsscene.

qpointf mainwindow::pointlocation(double bearing, double range){     int offset = 90; //used offset cartesian system     double centerx = 180;//push center location out halfway point     double centery = 180;     double newx = centerx + qcos(qdegreestoradians(bearing - offset)) * range;     double newy = centery + qsin(qdegreestoradians(bearing - offset)) * range;     qpointf newpoint = qpointf(newx, newy);     return newpoint;  } 

Comments

Popular posts from this blog

asynchronous - C# WinSCP .NET assembly: How to upload multiple files asynchronously -

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -