1

I've been searching for vector graphics and flash for quite some time but I haven't really found what I was looking for. Can anyone tell me exactly what area of mathematics is required for building vector images in 3D space? Is this just vector math? I saw some C++ libraries for it but I wasn't sure if it was the sort of vectors meant to for smaller file size like flash images are. Thanks in advance.

Louisrr
  • 145
  • 1
  • 8
  • 1
    You can use linear algebra (vector math). You also can do it more awkwardly using trigonometry. – Drew Dormann Jun 19 '14 at 18:57
  • 1
    There's usually not that much classroom math involved in things like that, unless you're constructing an API and dealing with a lot of low-level concepts and optimizations. – Panzercrisis Jun 19 '14 at 19:00
  • @starjamz what do you mean by flash? btw here is almost identical question http://stackoverflow.com/a/21100338/2521214 and here is how to rasterize 3D closed convex polygon to 2D screen http://stackoverflow.com/a/19078088/2521214 If you have concave polygons then you have to triangulate or bisect them google earclipping for starters. Also there is big difference if you use surface area representation or analytic representation of your models ... for analytics is raytraceing better – Spektre Jul 02 '14 at 09:38

1 Answers1

1

If you're wanting to do something from scratch (there are plenty of open-source libraries out there if you don't), keep in mind that "vector graphics" (this is different than the idea of a 3D space vector) themselves are typically based on parametric curves like Bezier curves, which are essentially 3rd degree polynomials for each x, y, and/or z point parameterized from a value t that goes from 0 to 1. Now projecting the texture-map image you create with those curves (i.e., the so-called "vector graphics" image) onto triangle polygon via uv coordinates would involve some interpolation, which is fairly straight forward linear algebra, as you would utilize the barycentric coordinate of the 3D point on the surface of the triangle polygon in order to calculate the uv point you want to look-up from the texture.

So essentially the steps are:

  1. Create the parametric-curve based image (i.e, the "vector graphic") and make a texture map out of it
  2. That texture map will have uv coordinates
  3. When you rasterize the 3D triangle polygon, you will get a barycentric coordinate on the surface of the triangle from the actual 3D points of the triangle polygon. Those points of the polygon should also have UV coordinates assigned to them.
  4. Use the barycentric coordinates to calculate the uv coordinate on the texture map.
  5. When you get that color from the texture map, then shade the triangle (i.e, calculate lighting, etc. if that's what you're doing, or just save that color of the pixel if there is no lighting).

Please note I haven't gotten into antialiasing, that's a completely different beast. Best thing if you don't know what you're doing there is to simply brute-force antialias through super-sampling (i.e., render a really big image and then average pixels to shrink it back to the desired size).

If you've taken multivariable calculus, the concepts behind parametric curves and surfaces should be familiar, and a basic understanding of linear algebra would be necessary in order to work with barycentric coordinates and linear interpolation from 3D vectors.

Jason
  • 31,834
  • 7
  • 59
  • 78
  • If you rasterize the polygons you're just making bitmap images are you not? – Louisrr Jun 20 '14 at 01:04
  • Yes, in the end you have to create a bitmap if you want to draw something to the screen. Screen buffers work with pixels. The "internal" representation in your data structures is resolution independent though, and that is the important thing to note. – Jason Jun 20 '14 at 12:34
  • 1
    (+1 nice summary) just need to add there is a bit more to it so just few hints to google for: Z-Buffering, Z-sorting. multidimensional interpolations (DDA,Bresenham), (back)raytracing, homogenous coordinates, transform matrix, triangulation, rasterisation, ... – Spektre Jul 02 '14 at 09:45