MCPcopy Create free account
hub / github.com/ObEngine/ObEngine / setPointPosition

Method setPointPosition

src/Core/Transform/Rect.cpp:136–181  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

134 }
135
136 void Rect::setPointPosition(const UnitVector& position, const Referential& ref)
137 {
138 const UnitVector oppositePointPosition = this->getPosition(ref.flip());
139 const double radAngle = Utils::Math::convertToRadian(-m_angle);
140 const UnitVector movedPoint
141 = rotatePointAroundCenter(position, oppositePointPosition, -radAngle);
142
143 this->setPosition(position, ref);
144
145 if (ref.isOnCorner())
146 {
147 if (ref.isOnTopSide())
148 {
149 this->setSize(
150 { movedPoint.x - position.x, movedPoint.y - position.y }, ref);
151 }
152 else
153 {
154 this->setSize(
155 { position.x - movedPoint.x, position.y - movedPoint.y }, ref);
156 }
157 }
158 if (ref.isOnLeftSide() || ref.isOnRightSide())
159 {
160 if (ref.isOnLeftSide())
161 {
162 this->setSize({ movedPoint.x - position.x, m_size.y }, ref);
163 }
164 else
165 {
166 this->setSize({ position.x - movedPoint.x, m_size.y }, ref);
167 }
168 }
169 else // we are on TopSide or BottomSide here, no need to specify the
170 // condition
171 {
172 if (ref.isOnTopSide())
173 {
174 this->setSize({ m_size.x, movedPoint.y - position.y }, ref);
175 }
176 else
177 {
178 this->setSize({ m_size.x, position.y - movedPoint.y }, ref);
179 }
180 }
181 }
182
183 UnitVector Rect::getPosition(const Referential& ref) const
184 {

Callers 1

LoadClassRectFunction · 0.45

Calls 10

getPositionMethod · 0.95
setPositionMethod · 0.95
setSizeMethod · 0.95
convertToRadianFunction · 0.85
rotatePointAroundCenterFunction · 0.85
flipMethod · 0.80
isOnCornerMethod · 0.80
isOnTopSideMethod · 0.80
isOnLeftSideMethod · 0.80
isOnRightSideMethod · 0.80

Tested by

no test coverage detected