Вопрос

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