SDXFrameWork 0.09 SDXFrameWork

- Main Page
- Related Pages
- Classes

All Classes Namespaces Functions Variables Enumerations Enumerator Pages
Shape.h
1 #pragma once//©SDXFramework http://sourceforge.jp/projects/dxframework/
2 //#include <Framework/Camera.h>
3 #include <Framework/IShape .h>
4
5 namespace SDX
6 {
7 class Complex;
8 class Point;
9 class Line;
10 class Circle;
11 class Rect;
12
13 class Camera;
14 class Color;
15
18 class Complex : public IShape
19 {
20 public:
21 std::vector<IShape*> shapes;
22
23 Complex(){};
24
25 Complex(IShape *shape)
26 {
27 shapes.push_back( shape );
28 }
29
30 IShape* Clone(double x,double y) const
31 {
32 Complex *buf = new Complex();
33
34 for( auto it: shapes )
35 {
36 buf->shapes.push_back( it );
37 }
38
39 return buf;
40 }
41
42 void SetPos(double X座標 , double Y座標)
43 {
44 for( auto it: shapes )
45 {
46 it->SetPos( X座標 , Y座標 );
47 }
48 }
49
50 void Move(double X移動量 , double Y移動量)
51 {
52 for( auto it: shapes )
53 {
54 it->Move( X移動量 , Y移動量 );
55 }
56 }
57
58 double GetX() const
59 {
60 return shapes[0]->GetX();
61 }
62
63 double GetY() const
64 {
65 return shapes[0]->GetY();
66 }
67
68 double GetW() const
69 {
70 return shapes[0]->GetW();
71 }
72
73 double GetH() const
74 {
75 return shapes[0]->GetH();
76 }
77
78 void MultiZoom(double X倍率 , double Y倍率)
79 {
80 for( auto it: shapes )
81 {
82 it->MultiZoom(X倍率, Y倍率);
83 }
84 zoomX *= X倍率;
85 zoomY *= Y倍率;
86 }
87
88 void Rotate(double 回転する角度)
89 {
90 for( auto it: shapes )
91 {
92 it->Rotate( 回転する角度 );
93 }
94 }
95
96 void SetAngle(double 指定角度)
97 {
98 for( auto it: shapes )
99 {
100 it->SetAngle( 指定角度 );
101 }
102 }
103
104 void Draw(Color 描画色, int 透過率, Camera *座標変換Camera = nullptr) const;
105
106 bool Hit(const IShape *shape) const
107 {
108 return shape->Hit( this );
109 }
110 bool Hit(const Complex *complex) const
111 {
112 for( auto itA : this->shapes )
113 {
114 for( auto itB : this->shapes )
115 {
116 if( itA->Hit(itB) ) return true;
117 }
118 }
119 return false;
120 }
121 bool Hit(const Point *point) const;
122 bool Hit(const Line *line) const;
123 bool Hit(const Rect *rect) const;
124 bool Hit(const Circle *circle) const;
125 };
126
129 class Point : public IShape
130 {
131 public:
132 double x;
133 double y;
134
135 Point() :
136 x(0),
137 y(0)
138 {};
139
140 Point(double X座標 , double Y座標):
141 x(X座標),
142 y(Y座標)
143 {}
144
145 template<class TA, class TB>
146 Point(TA X座標, TB Y座標) :
147 x(X座標),
148 y(Y座標)
149 {}
150
151 IShape* Clone(double X座標,double Y座標) const
152 {
153 auto shape = new Point( X座標 , Y座標 );
154 shape->zoomX = this->zoomX;
155 shape->zoomY = this->zoomY;
156 return shape;
157 }
158
159 void SetPos(double X座標 , double Y座標)
160 {
161 this->x = X座標;
162 this->y = Y座標;
163 }
164
165 void Move(double X移動量 , double Y移動量)
166 {
167 this->x += X移動量;
168 this->y += Y移動量;
169 }
170
171 double GetX() const
172 {
173 return x;
174 }
175
176 double GetY() const
177 {
178 return y;
179 }
180
181 double GetW() const
182 {
183 return 1;
184 }
185
186 double GetH() const
187 {
188 return 1;
189 }
190
191 void MultiZoom(double X倍率 , double Y倍率)
192 {
193 zoomX *= X倍率;
194 zoomY *= Y倍率;
195 }
196
197 void Rotate(double 回転する角度){}
198
199 void SetAngle(double 指定角度){}
200
201 void Draw(Color 描画色, int 透過率, Camera *座標変換Camera = nullptr) const;
202
203 bool Hit(const IShape *shape) const
204 {
205 return shape->Hit( this );
206 }
207 bool Hit(const Complex *complex) const
208 {
209 for( auto it : complex->shapes )
210 {
211 if( it->Hit( this ) ) return true;
212 }
213 return false;
214 }
215 bool Hit(const Point *point) const
216 {
217 return ( point->x == this->x && point->y == this->y );
218 }
219 bool Hit(const Line *line) const;
220 bool Hit(const Rect *rect) const;
221 bool Hit(const Circle *circle) const;
222 };
223
226 class Line : public IShape
227 {
228 private:
229 virtual void CulParam()
230 {
231 CulLine();
232 }
233
234 void CulLine()
235 {
236 this->xA = x + cos( angle ) * lengthA;
237 this->yA = y + sin( angle ) * lengthA;
238 this->xB = x - cos( angle ) * lengthB;
239 this->yB = y - sin( angle ) * lengthB;
240 this->width = abs(this->xB - this->xA);
241 this->height = abs(this->yB - this->yA);
242 this->thickHarf = this->thick / 2;
243 this->thickPow = this->thick * this->thick / 4;
244 this->minX = std::min( xA , xB );
245 this->maxX = std::max( xA , xB );
246 this->minY = std::min( yA , yB );
247 this->maxY = std::max( yA , yB );
248 }
249
250 double x;
251 double y;
252 double xA;
253 double yA;
254 double xB;
255 double yB;
256 double thick;//半径
257
258 double angle;//角度
259
260 double lengthA;
261 double lengthB;
262
263 double width;
264 double height;
265 double thickHarf;//半径の二条
266 double thickPow;
267 double minX;
268 double minY;
269 double maxX;
270 double maxY;
271
272 public:
273
274 Line( double X中心座標 , double Y中心座標 , double 角度 , double 長さ , double 太さ):
275 x(X中心座標),
276 y(Y中心座標),
277 angle( 角度 ),
278 lengthA( 長さ/2 ),
279 lengthB( 長さ/2 ),
280 thick( 太さ )
281 {
282 this->CulLine();
283 }
284
285 Line(double X中心座標, double Y中心座標, double 角度, double 前方長さ , double 後方長さ , double 太さ) :
286 x(X中心座標),
287 y(Y中心座標),
288 angle(角度),
289 lengthA(前方長さ),
290 lengthB(後方長さ),
291 thick(太さ)
292 {
293 this->CulLine();
294 }
295
296 virtual IShape* Clone(double X座標,double Y座標) const
297 {
298 auto shape = new Line( X座標 , Y座標 , this->angle , this->lengthA , this->thick);
299 shape->zoomX = this->zoomX;
300 shape->zoomY = this->zoomY;
301 return shape;
302 }
303
304 double GetX() const
305 {
306 return x;
307 }
308
309 double GetY() const
310 {
311 return y;
312 }
313
314 double GetW() const
315 {
316 return int(xA - xB);
317 }
318
319 double GetH() const
320 {
321 return int(yA - yB);
322 }
323
324 void SetPos(double X座標 , double Y座標 )
325 {
326 this->x = X座標;
327 this->y = Y座標;
328 this->CulParam();
329 }
330
331 void MultiZoom(double X倍率 , double Y倍率)
332 {
333 this->lengthA *= X倍率;
334 this->lengthB *= Y倍率;
335 this->thick *= X倍率;
336
337 this->CulParam();
338
339 zoomX *= X倍率;
340 zoomY *= Y倍率;
341 }
342
343 void Rotate(double 回転する角度)
344 {
345 this->angle += 回転する角度;
346 this->CulParam();
347 }
348
349 void SetAngle(double 指定角度)
350 {
351 this->angle = 指定角度;
352 this->CulParam();
353 }
354
355 void Move(double X移動量 , double Y移動量 )
356 {
357 this->x += X移動量;
358 this->y += Y移動量;
359 this->xA += X移動量;
360 this->yA += Y移動量;
361 this->xB += X移動量;
362 this->yB += Y移動量;
363
364 this->minX += X移動量;
365 this->minY += Y移動量;
366 this->maxX += X移動量;
367 this->maxY += Y移動量;
368 }
369
370 void Draw(Color 描画色, int 透過率, Camera *座標変換Camera = nullptr) const;
371
372 double GetXA() const
373 {
374 return xA;
375 }
376
377 double GetYA() const
378 {
379 return yA;
380 }
381
382 double GetXB() const
383 {
384 return xB;
385 }
386
387 double GetYB() const
388 {
389 return yB;
390 }
391
392 double GetThick() const
393 {
394 return thick;
395 }
396
397 void SetThick(double 太さ)
398 {
399 thick = 太さ;
400 thickHarf = int(thick / 2);
401 thickPow = int(thick * thick / 4);
402 }
403
404 double GetAngle() const
405 {
406 return this->angle;
407 }
408
409 double GetLength() const
410 {
411 return this->lengthA + this->lengthB;
412 }
413
414 double GetThickHarf() const
415 {
416 return this->thickHarf;
417 }
418
419 double GetThickPow() const
420 {
421 return this->thickPow;
422 }
423
424 double GetMinX() const
425 {
426 return minX;
427 }
428
429 double GetMinY() const
430 {
431 return minY;
432 }
433
434 double GetMaxX() const
435 {
436 return maxX;
437 }
438
439 double GetMaxY() const
440 {
441 return maxY;
442 }
443
444 bool Hit(const IShape *shape) const
445 {
446 return shape->Hit( this );
447 }
448 bool Hit(const Complex *complex) const
449 {
450 for( auto it : complex->shapes )
451 {
452 if( it->Hit( this ) ) return true;
453 }
454 return false;
455 }
456 bool Hit(const Point *point) const
457 {
458 return LinePoint( point->GetX() , point->GetY() , this->GetThick() );
459 }
460 bool Hit(const Line *line) const
461 {
462 //四角形でラフチェック
463 if( RectRect(this->GetXA() - this->GetThickHarf() ,this->GetYA() - this->GetThickHarf() , this->GetXB() - line->GetThickHarf() , this->GetYB() - line->GetThickHarf() ,
464 line->GetXA() - this->GetThickHarf() ,line->GetYA() - this->GetThickHarf() , line->GetXB() - line->GetThickHarf() , line->GetYB() - line->GetThickHarf() ) )
465 {
466 return true;
467 }
468 //交差チェック
469 if( LineLine(this->GetXA() ,this->GetYA() ,this->GetXB() ,this->GetYB() ,line->GetXA(),line->GetYA(),line->GetXB(),line->GetYB() ) )
470 {
471 return true;
472 }
473 //線と端のチェック
474 //線が点になっているかで分ける
475 if( this->GetLength() != 0)
476 {
477 if( this->LinePoint( line->GetXA() , line->GetYA() , this->GetThickHarf() + line->GetThickHarf() ) ) return true;
478 if( this->LinePoint( line->GetXB() , line->GetYB() , this->GetThickHarf() + line->GetThickHarf() ) ) return true;
479 }
480 if( line->GetLength() != 0 )
481 {
482 if( line->LinePoint( this->GetXA() , this->GetYA() , this->GetThickHarf() + line->GetThickHarf() ) ) return true;
483 if( line->LinePoint( this->GetXB() , this->GetYB() , this->GetThickHarf() + line->GetThickHarf() ) ) return true;
484 }
485
486 return false;
487 }
488 bool Hit(const Rect *rect) const;
489 bool Hit(const Circle *circle) const;
490
492 bool LinePoint(double px , double py , double range ) const
493 {
494 //点同士の距離
495 const double dx = GetXB() - GetXA();
496 const double dy = GetYB() - GetYA();
497
498 const double a = dx * dx + dy * dy;
499 const double b = dx *(GetXA() - px) + dy *(GetYA() - py);
500
501 //点の場合
502 if (a == 0)
503 {
504 if(
505 ( GetXA() - px ) *( GetXA() - px ) +
506 ( GetYA() - py ) *( GetYA() - py )
507 < range * range ) return true;
508 return false;
509 }
510
511 const double t = -b / a;
512
513 const double tx = GetXA() + dx*t;
514 const double ty = GetYA() + dy*t;
515
516 //線分上の点が範囲内かチェック
517 if ( tx < minX || tx > maxX || ty < minY || ty > maxY)
518 {
519 if (
520 (xA - px) * (xA - px) + (yA - py) * (yA - py) > range * range &&
521 (xB - px) * (xB - px) + (yB - py) * (yB - py) > range * range
522 )
523 {
524 return false;
525 }
526 }
527
528 const double d = (px - tx)*(px - tx) + (py - ty) * (py - ty);
529
530 return (d < range * range);
531 }
532 };
533
536 class Rect : public IShape
537 {
538 public:
539 double x;
540 double y;
541
542 double widthLeft;
543 double widthRight;
544
545 double heightUp;
546 double heightDown;
547
548 /*座標と大きさを指定*/
549 /*デフォルト引数だと左上座標と大きさを指定*/
550 /*横幅A=横幅B,高さA=高さBとすると中心座標指定になる*/
551 Rect(double X座標,double Y座標,double 横幅A ,double 高さA, double 横幅B = 0 , double 高さB = 0):
552 x(X座標),
553 y(Y座標),
554 heightUp( 高さB ),
555 heightDown( 高さA ),
556 widthLeft( 横幅B ),
557 widthRight( 横幅A )
558 {}
559
560 template <class T>
561 Rect(T X座標, T Y座標, T 横幅A, T 高さA, T 横幅B = 0, T 高さB = 0) :
562 x((double)X座標),
563 y((double)Y座標),
564 heightUp((double)高さB),
565 heightDown((double)高さA),
566 widthLeft((double)横幅B),
567 widthRight((double)横幅A)
568 {}
569
570
571 virtual IShape* Clone(double X座標,double Y座標) const
572 {
573 auto shape = new Rect( X座標 , Y座標 , widthRight , heightDown , widthLeft , heightUp );
574 shape->zoomX = this->zoomX;
575 shape->zoomY = this->zoomY;
576 return shape;
577 }
578
579 void SetPos(double X座標 , double Y座標)
580 {
581 this->x = X座標;
582 this->y = Y座標;
583 }
584
585 void Move(double X移動量 , double Y移動量 )
586 {
587 this->x += X移動量;
588 this->y += Y移動量;
589 }
590
591 void MultiZoom(double X倍率 , double Y倍率)
592 {
593 widthLeft *= X倍率;
594 widthRight *= X倍率;
595
596 heightUp *= Y倍率;
597 heightDown *= Y倍率;
598 }
599
600 void Rotate(double 回転する角度){}
601
602 void SetAngle(double 指定角度){}
603
604 void Draw( Color 描画色 , int 透過率 , Camera *座標変換Camera = nullptr) const;
605
606 inline double GetX() const
607 {
608 return x;
609 }
610
611 inline double GetY() const
612 {
613 return y;
614 }
615
616 inline double GetW() const
617 {
618 return widthLeft + widthRight;
619 }
620
621 inline double GetH() const
622 {
623 return heightUp + heightDown;
624 }
625
626 inline double GetLeft() const
627 {
628 return x - widthLeft;
629 }
630
631 inline double GetTop() const
632 {
633 return y - heightUp;
634 }
635
636 inline double GetRight() const
637 {
638 return x + widthRight;
639 }
640
641 inline double GetBottom() const
642 {
643 return y + heightDown;
644 }
645
646 bool Hit(const IShape *shape) const
647 {
648 return shape->Hit( this );
649 }
650 bool Hit(const Complex *complex) const
651 {
652 for( auto it : complex->shapes )
653 {
654 if( it->Hit( this ) ) return true;
655 }
656 return false;
657 }
658 bool Hit(const Point *point) const
659 {
660 return (
661 (
662 point->x < this->GetRight()
663 ) && (
664 point->x > this->GetLeft()
665 ) && (
666 point->y < this->GetBottom()
667 ) && (
668 point->y > this->GetTop()
669 )
670 );
671 }
672 bool Hit(const Line *line) const
673 {
674 if (
675 !(
676 line->GetMaxX() + line->GetThickHarf() < this->GetLeft() ||
677 line->GetMinX() - line->GetThickHarf() > this->GetTop() ||
678 line->GetMaxY() + line->GetThickHarf() < this->GetRight() ||
679 line->GetMinY() - line->GetThickHarf() > this->GetBottom()
680 )
681 )
682 {
683 return false;
684 }
685
686 //√２/2≒0.7
687 if( LineLine( line->GetXA() , line->GetYA() , line->GetXB() , line->GetYB()
688 , this->GetLeft() - int(line->GetThickHarf() * 0.7) , this->GetTop() - int(line->GetThickHarf() * 0.7) , this->GetRight() + int(line->GetThickHarf() * 0.7) , this->GetBottom() + int(line->GetThickHarf() * 0.7) ))
689 {
690 return true;
691 }
692
693 if( LineLine( line->GetXA() , line->GetYA() , line->GetXB() , line->GetYB()
694 , this->GetRight() + int(line->GetThickHarf() * 0.7) , this->GetTop() - int(line->GetThickHarf() * 0.7) , this->GetLeft() - int(line->GetThickHarf() * 0.7) , this->GetBottom() + int(line->GetThickHarf() * 0.7) ))
695 {
696 return true;
697 }
698
699 //端の丸い所以外判定
700 if(
701 line->GetXA() + line->GetThickHarf() > this->GetLeft() && line->GetXA() - line->GetThickHarf() < this->GetRight() &&
702 line->GetYA() + line->GetThickHarf() > this->GetTop() && line->GetYA() - line->GetThickHarf() < this->GetBottom()
703 )
704 {
705 //端の丸い所判定
706 if( line->GetXA() < this->GetLeft() && line->GetYA() < this->GetTop() )
707 {//左上
708
709 if( (line->GetXA() - this->GetLeft()) * (line->GetXA() - this->GetLeft()) +
710 (line->GetYA() - this->GetTop()) * (line->GetYA() - this->GetTop()) < line->GetThickPow() ) return true;
711
712 }
713 else if( line->GetXA() > this->GetRight() && line->GetYA() < this->GetTop() )
714 {//右上
715
716 if( (line->GetXA() - this->GetRight()) * (line->GetXA() - this->GetRight()) +
717 (line->GetYA() - this->GetTop()) * (line->GetYA() - this->GetTop()) < line->GetThickPow() ) return true;
718
719 }
720 else if( line->GetXA() < this->GetLeft() && line->GetYA() > this->GetBottom() )
721 {//左下
722
723 if( (line->GetXA() - this->GetLeft()) * (line->GetXA() - this->GetLeft()) +
724 (line->GetYA() - this->GetBottom()) * (line->GetYA() - this->GetBottom()) < line->GetThickPow() ) return true;
725
726 }
727 else if( line->GetXA() > this->GetRight() && line->GetYA() > this->GetBottom() )
728 {//右下
729
730 if( (line->GetXA() - this->GetRight()) * (line->GetXA() - this->GetRight()) +
731 (line->GetYA() - this->GetBottom()) * (line->GetYA() - this->GetBottom()) < line->GetThickPow() ) return true;
732
733 }
734 else
735 {
736 return true;
737 }
738 }
739
740 if(
741 line->GetXB() + line->GetThickHarf() > this->GetLeft() && line->GetXB() - line->GetThickHarf() < this->GetRight() &&
742 line->GetYB() + line->GetThickHarf() > this->GetTop() && line->GetYB() - line->GetThickHarf() < this->GetBottom()
743 )
744 {
745 //端の丸い所判定
746 if( line->GetXB() < this->GetLeft() && line->GetYB() < this->GetTop() )
747 {//左上
748 if( (line->GetXB() - this->GetLeft()) * (line->GetXB() - this->GetLeft()) +
749 (line->GetYB() - this->GetTop()) * (line->GetYB() - this->GetTop()) < line->GetThickPow() ) return true;
750
751 }
752 else if( line->GetXB() > this->GetRight() && line->GetYB() < this->GetTop() )
753 {//右上
754
755 if( (line->GetXB() - this->GetRight()) * (line->GetXB() - this->GetRight()) +
756 (line->GetYB() - this->GetTop()) * (line->GetYB() - this->GetTop()) < line->GetThickPow() ) return true;
757
758 }
759 else if( line->GetXB() < this->GetLeft() && line->GetYB() > this->GetBottom() )
760 {//左下
761
762 if( (line->GetXB() - this->GetLeft()) * (line->GetXB() - this->GetLeft()) +
763 (line->GetYB() - this->GetBottom()) * (line->GetYB() - this->GetBottom()) < line->GetThickPow() ) return true;
764
765 }
766 else if( line->GetXB() > this->GetRight() && line->GetYB() > this->GetBottom() )
767 {//右下
768 if( (line->GetXB() - this->GetRight()) * (line->GetXB() - this->GetRight()) +
769 (line->GetYB() - this->GetBottom()) * (line->GetYB() - this->GetBottom()) < line->GetThickPow() ) return true;
770
771 }
772 else
773 {
774 return true;
775 }
776 }
777
778 return false;
779 }
780 bool Hit(const Rect *rect) const
781 {
782 return !(GetRight() < rect->GetLeft() || GetLeft() > rect->GetRight() || GetBottom() < rect->GetTop() || GetTop() > rect->GetBottom() );
783 }
784 bool Hit(const Circle *circle) const;
785 };
786
789 class Circle : public IShape
790 {
791 public:
792 double x;
793 double y;
794 double radius;
795
796 Circle( double X座標 , double Y座標 , double 半径):
797 x(X座標),
798 y(Y座標),
799 radius(半径)
800 {}
801
802 IShape* Clone(double X座標,double Y座標) const
803 {
804 auto shape = new Circle( X座標 , Y座標 , this->radius );
805 shape->zoomX = this->zoomX;
806 shape->zoomY = this->zoomY;
807 return shape;
808 }
809
810 void SetPos(double X座標 , double Y座標 )
811 {
812 this->x = X座標;
813 this->y = Y座標;
814 }
815
816 void MultiZoom(double 倍率X , double 倍率Y)
817 {
818 this->radius *= 倍率X;
819
820 zoomX *= 倍率X;
821 zoomY *= 倍率Y;
822 }
823
824 void Rotate(double 回転する角度){}
825
826 void SetAngle(double 指定角度){}
827
828 void Move(double X移動量 , double Y移動量 )
829 {
830 this->x += X移動量;
831 this->y += Y移動量;
832 }
833
834 double GetX() const
835 {
836 return int(x);
837 }
838
839 double GetY() const
840 {
841 return int(y);
842 }
843
844 double GetW() const
845 {
846 return int(radius*2);
847 }
848
849 double GetH() const
850 {
851 return int(radius*2);
852 }
853
854 void Draw( Color 描画色 , int 透過率 , Camera *座標変換Camera = nullptr) const;
855
856 bool Hit(const IShape *shape) const
857 {
858 return shape->Hit( this );
859 }
860 bool Hit(const Complex *complex) const
861 {
862 for( auto it : complex->shapes )
863 {
864 if( it->Hit( this ) ) return true;
865 }
866 return false;
867 }
868 bool Hit(const Point *point) const
869 {
870 return
871 (
872 ( point->x - this->x ) * ( point->x - this->x ) +
873 ( point->y - this->y ) * ( point->y - this->y )
874 <=
875 ( this->radius * this->radius )
876 );
877 }
878 bool Hit(const Line *line) const
879 {
880 return line->LinePoint( x , y , (line->GetThickHarf() + radius) );
881 }
882 bool Hit(const Circle *circle) const
883 {
884 return(
885 (this->x - circle->x) * (this->x - circle->x) +
886 (this->y - circle->y) * (this->y - circle->y)
887 <=
888 (this->radius + circle->radius) * (this->radius + circle->radius)
889 );
890 }
891 bool Hit(const Rect *rect) const
892 {
893 return
894 (
895 (
896 (
897 (
898 this->x + this->radius >= rect->GetLeft()
899 )&&(
900 this->x - this->radius <= rect->GetRight()
901 )
902 )&&(
903 (
904 this->y >= rect->GetTop()
905 )&&(
906 this->y <= rect->GetBottom()
907 )
908 )
909 ) || (
910 (
911 (
912 this->x >= rect->GetLeft()
913 )&&(
914 this->x <= rect->GetRight()
915 )
916 )&&(
917 (
918 this->y + this->radius >= rect->GetTop()
919 )&&(
920 this->y - this->radius <= rect->GetBottom()
921 )
922 )
923 ) || (//四角形の四隅と円の判定
924 (this->x - rect->GetLeft() ) * (this->x - rect->GetLeft() ) +
925 (this->y - rect->GetTop() ) * (this->y - rect->GetTop() ) <=
926 (this->radius * this->radius )
927 ) || (
928 (this->x - rect->GetRight()) * (this->x - rect->GetRight()) +
929 (this->y - rect->GetTop() ) * (this->y - rect->GetTop() ) <=
930 (this->radius * this->radius )
931 ) || (
932 (this->x - rect->GetLeft()) * (this->x - rect->GetLeft()) +
933 (this->y - rect->GetBottom()) * (this->y -rect->GetBottom()) <=
934 (this->radius * this->radius )
935 ) || (
936 (this->x - rect->GetRight()) * (this->x - rect->GetRight()) +
937 (this->y - rect->GetBottom()) * (this->y - rect->GetBottom()) <=
938 (this->radius * this->radius )
939 )
940 );
941 }
942 };
943 }
SDX::Point::Rotate
void Rotate(double 回転する角度)
回転する.
Definition: Shape.h:197
SDX::Complex::MultiZoom
void MultiZoom(double X倍率, double Y倍率)
縦横別で拡大率を掛け算する.
Definition: Shape.h:78
SDX::Circle::Hit
bool Hit(const IShape *shape) const
衝突判定.
Definition: Shape.h:856
SDX::Point::MultiZoom
void MultiZoom(double X倍率, double Y倍率)
縦横別で拡大率を掛け算する.
Definition: Shape.h:191
SDX::Point::Clone
IShape * Clone(double X座標, double Y座標) const
同じ形の図形を作る.
Definition: Shape.h:151
SDX::Rect
矩形を表す図形クラス.
Definition: Shape.h:536
SDX::Point::Hit
bool Hit(const IShape *shape) const
衝突判定.
Definition: Shape.h:203
SDX::Rect::GetX
double GetX() const
X座標を取得.
Definition: Shape.h:606
SDX::Rect::GetW
double GetW() const
幅を取得.
Definition: Shape.h:616
SDX::Line
太さのある線を表す図形クラス.
Definition: Shape.h:226
SDX::Rect::GetY
double GetY() const
Y座標を取得.
Definition: Shape.h:611
SDX::Rect::Draw
void Draw(Color 描画色, int 透過率, Camera *座標変換Camera=nullptr) const
描画する.
Definition: ShapeDraw.h:46
SDX::Complex::Draw
void Draw(Color 描画色, int 透過率, Camera *座標変換Camera=nullptr) const
描画する.
Definition: ShapeDraw.h:6
SDX::Point::GetW
double GetW() const
幅を取得.
Definition: Shape.h:181
SDX::Point::GetY
double GetY() const
Y座標を取得.
Definition: Shape.h:176
SDX::Point::SetAngle
void SetAngle(double 指定角度)
角度を指定する.
Definition: Shape.h:199
SDX::Rect::SetPos
void SetPos(double X座標, double Y座標)
指定座標に移動.
Definition: Shape.h:579
SDX::Rect::SetAngle
void SetAngle(double 指定角度)
角度を指定する.
Definition: Shape.h:602
SDX::Line::Clone
virtual IShape * Clone(double X座標, double Y座標) const
同じ形の図形を作る.
Definition: Shape.h:296
SDX::Complex::Move
void Move(double X移動量, double Y移動量)
相対座標で移動.
Definition: Shape.h:50
SDX::Complex::Clone
IShape * Clone(double x, double y) const
同じ形の図形を作る.
Definition: Shape.h:30
SDX::Circle::SetPos
void SetPos(double X座標, double Y座標)
指定座標に移動.
Definition: Shape.h:810
SDX::Complex::GetX
double GetX() const
X座標を取得.
Definition: Shape.h:58
SDX::Point
点を表す図形クラス.
Definition: Shape.h:129
SDX::Point::Move
void Move(double X移動量, double Y移動量)
相対座標で移動.
Definition: Shape.h:165
SDX::Point::GetX
double GetX() const
X座標を取得.
Definition: Shape.h:171
SDX::Line::Draw
void Draw(Color 描画色, int 透過率, Camera *座標変換Camera=nullptr) const
描画する.
Definition: ShapeDraw.h:28
SDX::Rect::Rotate
void Rotate(double 回転する角度)
回転する.
Definition: Shape.h:600
SDX::IShape
位置情報を持つ図形の抽象クラス.
Definition: IShape .h:18
SDX::Rect::Move
void Move(double X移動量, double Y移動量)
相対座標で移動.
Definition: Shape.h:585
SDX::Complex
複合図形を表すクラス.
Definition: Shape.h:18
SDX::Complex::Rotate
void Rotate(double 回転する角度)
回転する.
Definition: Shape.h:88
SDX::Line::GetW
double GetW() const
幅を取得.
Definition: Shape.h:314
SDX::Circle::GetW
double GetW() const
幅を取得.
Definition: Shape.h:844
SDX::Complex::GetW
double GetW() const
幅を取得.
Definition: Shape.h:68
SDX::Circle::GetX
double GetX() const
X座標を取得.
Definition: Shape.h:834
SDX::Complex::SetPos
void SetPos(double X座標, double Y座標)
指定座標に移動.
Definition: Shape.h:42
SDX::Point::Draw
void Draw(Color 描画色, int 透過率, Camera *座標変換Camera=nullptr) const
描画する.
Definition: ShapeDraw.h:14
SDX::Line::Hit
bool Hit(const IShape *shape) const
衝突判定.
Definition: Shape.h:444
SDX::Circle::Draw
void Draw(Color 描画色, int 透過率, Camera *座標変換Camera=nullptr) const
描画する.
Definition: ShapeDraw.h:80
SDX::Color
色を表すクラス.
Definition: Color.h:7
SDX::Complex::SetAngle
void SetAngle(double 指定角度)
角度を指定する.
Definition: Shape.h:96
SDX::Line::SetAngle
void SetAngle(double 指定角度)
角度を指定する.
Definition: Shape.h:349
SDX::Rect::MultiZoom
void MultiZoom(double X倍率, double Y倍率)
縦横別で拡大率を掛け算する.
Definition: Shape.h:591
SDX::Line::Move
void Move(double X移動量, double Y移動量)
相対座標で移動.
Definition: Shape.h:355
SDX::IShape::Hit
virtual bool Hit(const IShape *IShape) const =0
衝突判定.
SDX::IShape::LineLine
static bool LineLine(double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4)
線分の交差判定.
Definition: IShape .h:62
SDX::Complex::GetY
double GetY() const
Y座標を取得.
Definition: Shape.h:63
SDX::Line::GetY
double GetY() const
Y座標を取得.
Definition: Shape.h:309
SDX::Circle::GetH
double GetH() const
高さを取得.
Definition: Shape.h:849
SDX::Point::SetPos
void SetPos(double X座標, double Y座標)
指定座標に移動.
Definition: Shape.h:159
SDX::Complex::GetH
double GetH() const
高さを取得.
Definition: Shape.h:73
SDX::Circle::Clone
IShape * Clone(double X座標, double Y座標) const
同じ形の図形を作る.
Definition: Shape.h:802
SDX::Circle::SetAngle
void SetAngle(double 指定角度)
角度を指定する.
Definition: Shape.h:826
SDX::Camera
2D用に座標変換を行うカメラを表すクラス.
Definition: Camera.h:16
SDX::Line::LinePoint
bool LinePoint(double px, double py, double range) const
線と点の当たり判定.
Definition: Shape.h:492
SDX::Circle::Move
void Move(double X移動量, double Y移動量)
相対座標で移動.
Definition: Shape.h:828
SDX::Point::GetH
double GetH() const
高さを取得.
Definition: Shape.h:186
SDX::Rect::Clone
virtual IShape * Clone(double X座標, double Y座標) const
同じ形の図形を作る.
Definition: Shape.h:571
SDX::IShape::RectRect
static bool RectRect(double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4)
矩形の交差判定.
Definition: IShape .h:25
SDX::Circle::Rotate
void Rotate(double 回転する角度)
回転する.
Definition: Shape.h:824
SDX::Line::GetX
double GetX() const
X座標を取得.
Definition: Shape.h:304
SDX::Circle
円を表す図形クラス.
Definition: Shape.h:789
SDX::Circle::GetY
double GetY() const
Y座標を取得.
Definition: Shape.h:839
SDX::Line::SetPos
void SetPos(double X座標, double Y座標)
指定座標に移動.
Definition: Shape.h:324
SDX::Line::MultiZoom
void MultiZoom(double X倍率, double Y倍率)
縦横別で拡大率を掛け算する.
Definition: Shape.h:331
SDX::Circle::MultiZoom
void MultiZoom(double 倍率X, double 倍率Y)
縦横別で拡大率を掛け算する.
Definition: Shape.h:816
SDX::Rect::Hit
bool Hit(const IShape *shape) const
衝突判定.
Definition: Shape.h:646
SDX::Line::Rotate
void Rotate(double 回転する角度)
回転する.
Definition: Shape.h:343
SDX::Complex::Hit
bool Hit(const IShape *shape) const
衝突判定.
Definition: Shape.h:106
SDX::Line::GetH
double GetH() const
高さを取得.
Definition: Shape.h:319
SDX::Rect::GetH
double GetH() const
高さを取得.
Definition: Shape.h:621