Bezier Lines and Matrix Transformations

Blitz3D Forums/Blitz3D Programming/Bezier Lines and Matrix Transformations

CompuWiz(Posted 2004) [#1]
Hello,

My name is Nick Small, and I'm new to the Blitz forums but I've been using Blitz for at least a year. Anyways, I'm having some trouble with mathematically-generated lines. I'm using a system of bezier lines of which the user can manipulate, and therefore change the lines. The lines are constantly being redrawn on screen (every loop), so that whenever the user moves a point or a handle, the changes are reflected on screen. However, what I'd like to do is draw a second and a third line which are exact copies of the first line just enlarged or shrunk. So that instead of the user just seeing a line between the points (like so: | ), they would see a sort of road or track between the points (like so: ||| ). I'm just having trouble enlarging and shrinking the lines. I've tried scaling the points like a normal geometric figure by simply multiplying the points by 2 and 0.5. However this obviously didn't work. I tried simply adding and subtracting 5 from the X, Y, and Z coordinates. That didn't work either. Then I got some advice from someone. They basically said "for each point along the bezier line, you first generate a local coordinate system based on the direction at that point. Then you have a function that takes a coordinate in that local system and turns it into a global coordinate. You can generate this local coordinate system by using matrices." Well I'm just having lots and lots of problems with... well everything! If you have ANY ideas, I'd be happy to hear them. I've been TOTALLY stumped on this problem for a few weeks.

Thanks a lot,
Nick Small


Tiggertooth(Posted 2004) [#2]
There are several ways to accomplish what you want to accomplish. You can certainly do what they're suggesting, but maybe another description of it will be easier.

Are you comfortable with vector math? Normals and the like? I think you can accomplish a simplified version of what you want without dropping into matrices by taking the perpendicular of the vectors between your bezier points and displacing the verts by this perpendicular in a given plane.

If you think of the points along your spline, then the lines between the points can be thought of as vectors. You can use a normal to that vector in order to display the original line. You can do it in a simplistic way, such as displacing the points along the normal but keeping the y-value the same (so all lines have the same height). Now every point on your line can be offset at the same point. Connect those points with lines and presto there are your three lines.

Given that you're using bezier lines, I'm going to guess you are comfortable with much of this :-)

Ken


CompuWiz(Posted 2004) [#3]
Hi Ken,

Yes, I'm fairly familiar with Vector math. However your explanation was slightly confusing. Could you maybe try to go into a little bit more detail? Also, what do you mean by displace? I think I got what you meant, however if I did, then take a look at what I get (there's just 2 rails, I haven't even tried 3 yet):

Thanks again,
Nick Small.