I want to convert a set of coordinates into polar coordinates (the easy part), and then model them on a polar 3D grid. Is this possible using WebGL or are only Cartesian coordinates supported?

有帮助吗?

解决方案

You can implement any type of coordinate transform you want in shaders. However, there is an important restriction:

If you draw two connected vertices (i.e. a straight line, or the edge of a triangle), the result will always be a straight line on the screen — it is not possible to do otherwise in OpenGL.

The Cartesian-polar transform turns straight lines into curved lines. This means that if you want to transform a straight-sided shape and get the “right” curved result, you must draw it using a sequence of closely-spaced vertices — as many as you need to produce the “resolution” of smooth curvature you want. This is generally not hard to program, but it is something to be aware of.

其他提示

You can use shaders in webgl so you can give your inputs as polar coordinates and have webgl transform them to cartesian internally.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top