PDA

Click to See Complete Forum and Search --> : need some trig help (I think)



Smapdi636
05-17-2002, 10:47 AM
Hello.

I draw some lines based on lat/long points read from XML. I translate the lat/longs in to _x and _y and use moveTo/lineTo to draw the lines. The lines represent roadways (both directions).

What I want to do is OFFSET the lines by some number of pixels. I'll try to explain.

The roadways are so close together that when viewed from a "zoomed out" view, the seperate lanes of travel (Northbound and Southbound for example) are indistinguishable from one another. You have to zoom in really close to see that there are actually 2 lines.

So, I want to offset the roadways from their actual location and make the lines thicker.

See the following image - I hope it helps to illustrate my problem.

http://www.calmbomb.com/problem.jpg

Here's some trace output from my code where I plan to do the offsetting.

// begin trace output
just finished parsing the XML for a road segment

direction of travel is: 1 // either 1 or 0 tells which direction to offset in

the x & y points for the segment as stored in
segmentX[] and segmentY[] are:
418.764945945933,400.727933006534
415.841162162155,409.740212418297
412.593135135142,413.344771241833
412.918351351353,422.958300653594
404.797918918909,455.704256535938
402.524324324317,465.918300653583
395.054081081069,473.729550653585
390.506648648651,478.836609477116
384.335810810799,491.454256535935
381.737243243241,497.46241830064
377.839756756766,504.973006535934
378.164243243243,511.281830065352
381.737243243241,521.495947712409
385.310243243248,523.899477124172
391.156837837837,529.907712418288
392.131027027023,532.911756535941
// end trace output

Can someone help me with the math needed to do this offset?

Have I explained the problem enough?

TIA

Smapdi636
05-20-2002, 11:25 AM
Well no response for my initial post.

Hope this picture helps.

http://www.calmbomb.com/trig_problem.jpg

I need to be able to draw both unknown lines (the red and blue ones) based on the points of the known line (the green one), depending on direction (1 or 0). The unknown line's points must be 2 units away from the known line.

I'll have 2 arrays containing the known (green) line's x and y points.

knownLineX[0]: -14
knownLineX[1]: -5
knownLineX[2]: -4
knownLineX[3]: 3
knownLineX[4]: 9
knownLineX[5]: 12

knownLineY[0]: -16
knownLineY[1]: -9
knownLineY[2]: 4
knownLineY[3]: 9
knownLineY[4]: 8
knownLineY[5]: 4

Anyone?

TIA