开发者

Scaling a polygon toward an edge?

I know that to scale verticies I simply have to multiply by a scale factor. But I noticed that most vector drawing applications show the shapes bounding box and by dragging one of the edge it will scale the geometry toward the opposite edge, then if you go past this edge it will end up mirroring the geometry on that axis. How is scaling toward an edge done? Ex: If you select the topmost edge of a circle, it will s开发者_如何学Gocale toward the bottom edge of its bounding box until it looks like nothing, sort of like a raindrop that collapses when it hits the ground. I hope this is clear enough. Thanks


Keep track of the original distance between the two edges, and calculate the new edge distance as it is moved. Scale each point to the ratio of original/new, and use the edge that isn't moving as your zero point, i.e. subtract that value from each coordinate before scaling and add it back after scaling. Be careful not to crash when the two edges meet and the distance becomes zero.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜