Advertisement
this is not c++ specific, and I am working in c to implement it, but, I am starting to work on gradient fill routines, and for the linear version I need to draw lines perpendicular to the fill path. so, given a line from x1,y1 to x2,y2, how to I calculate end points for all of the perpendicular lines (one per pixel along my fill path)? any takers? hehe.. :)
Advertisement
Advertisement
-
Re: creating 90 degree perpendicular lines
Fri, July 21, 2006 - 2:56 PM -
-
Re: creating 90 degree perpendicular lines
Fri, July 21, 2006 - 3:05 PMthanks Jon, that's the answer I keep finding 'how to determine the point of intersection of two lines', but that's not the problem I am trying to solve...
I have one line, the 'fill path', and I need to create lines that are 90 degrees perpendicular to it... maybe that info is on the page you pointed me to, but I am 'higher level math challenged'.. :) I know my intersection point, ie. one point for each pixel along the fill path, now how do I generate the end points of each of those lines, to pass to a line drawing function?
-cpr -
-
Re: creating 90 degree perpendicular lines
Fri, July 21, 2006 - 3:13 PM -
-
Re: creating 90 degree perpendicular lines
Fri, July 21, 2006 - 3:18 PMJon, thanks again! This one looks much more promising.. I'll need to wade thru it still.. :)
peace
-cpr -
-
Re: creating 90 degree perpendicular lines
Fri, July 21, 2006 - 4:42 PMIm not sure how you are drawing your lines, but if you use a slope-intercept line equation (y= mx + b) a perpendicular line is any line with a slope of -1/m I believe. taking each point on the initial line, you can project the perpendicular lines out this way since you know each point on the first line is also on the perpendicular line. I dont if this helps for your gradient problem tho :)
-
-
-
-
-
Re: creating 90 degree perpendicular lines
Fri, July 21, 2006 - 6:20 PMHave you considered using a scan line approach instead of drawing a bunch of perpendicular lines?
-
-
Re: creating 90 degree perpendicular lines
Sat, July 22, 2006 - 11:39 PMThat could be done but the gradient wouldn't follow the edge of the triangle in that case without doing a spatial calculation on its distance from the vertices. I'm guessing he just wanted to interpolate between two RGB values following a straight path.
-
Re: creating 90 degree perpendicular lines
Mon, July 24, 2006 - 2:57 PMactually, I haven't considered any different approaches.. :) Graphics is not my area of specialily, but I will be implementing some gradient fill routines in the near future. So, I guess my real question could have been asking for advice in implementing gradient fills, both linear and circular.. my first idea for the non-circular fill was to draw the perpendicular lines all along the fill path.. I've written some code which calculates the colors for each line of the fill, but I don't know how to generate the co-ordinates for the series of lines to draw.. google searches have not provided me with much, except for some great stuff from Chris Lomont regarding circular gradient fills..
anyways, if anyone wants to point me to some other good sources regarding linear fills, etc, that would be great..
peace
-cpr -
-
Re: creating 90 degree perpendicular lines
Mon, July 31, 2006 - 12:59 PMwww.gamedev.net/reference/...icle323.asp
This may help or be a start. It sounds like you are trying to do your own Gouraud shading. There are other articles and discussions on the site. Shading a triangle can be quite an enormous topic.
-
-