how to make a polygon with direction of points?

조회 수: 4 (최근 30일)
Sierra
Sierra 2022년 5월 23일
답변: Walter Roberson 2022년 5월 23일
i want to make a polygon with direction of points like second polygon.
but what i can only make is first polygo which is i didn't intend to make.
the polygon should be made from mean point.
let me know how to draw a polygon with specific direction.
thanks!
  댓글 수: 4
Jan
Jan 2022년 5월 23일
My answer could be more specific, if you explain more specifically, what your input data are and what you want to get as output. Please post some code, which creates representative inputs. If I invent your data, the chance is to high, that my guess do not match and the time for typing my answer is wasted.
It is not even clear, what exactly you call a "polygon" here. What does this sentence mean: "the polygon should be made from mean point." Which is the "mena point" in the provided example?
Points do not have directions. What is the wanted output? The coordinates of the corners of the squares? Or do you want to draw it in a figure or in an image?
Sierra
Sierra 2022년 5월 23일
my input data are cooridnates, and the mean point is mean of a lot of coordinates.
i made a square using percentile.
what i want to know is how to rotate the square using angle between two points.
sorry for make you confused.

댓글을 달려면 로그인하십시오.

채택된 답변

Walter Roberson
Walter Roberson 2022년 5월 23일
You can create a transformation matrix. I recommend using makehgtform() . Transforms for it are applied right (last) to left (first). Typically you would subtract off the center of rotation, rotate, then add back the center of rotation... except in reverse order, so something like
M = makehgtform('translate', cx, cy, cz, 'xrotate', angle, 'translate', -cx, -cy, -cz)
You would then create coordinate lists for your points, [x(:), y(:), z(:), zeros(numel(x),1] and post-multiply by M to get transformed points.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Computational Geometry에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by