Skip to content
This repository

add rotateByAngle method with no garbage in CGPointUtil #48

Merged
merged 1 commit into from over 2 years ago

2 participants

Gwenn Guihal Zhou Weikuan
Gwenn Guihal

No description provided.

Zhou Weikuan

Thanks very much!
I will merge soon. And when I first use it, I will test it at the same time too:-)

Zhou Weikuan ZhouWeikuan merged commit ee6221f into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 1 unique commit by 1 author.

Nov 21, 2011
Gwenn Guihal myrddinus add rotateByAngle method with no garbage. 3f609b4
This page is out of date. Refresh to see the latest.
11 cocos2d-android/src/org/cocos2d/types/util/CGPointUtil.java
@@ -70,4 +70,15 @@ public static float distance(CGPoint p1, CGPoint p2) {
70 70 float dy = p2.y - p1.y;
71 71 return (float)Math.sqrt(dx * dx + dy * dy);
72 72 }
  73 +
  74 + public static void rotateByAngle(CGPoint v, CGPoint pivot, float angle, CGPoint ret)
  75 + {
  76 + CGPointUtil.sub(v, pivot,ret);
  77 + float t = ret.x;
  78 + float cosa = (float)Math.cos(angle);
  79 + float sina = (float)Math.sin(angle);
  80 + ret.x = t*cosa - ret.y*sina;
  81 + ret.y = t*sina + ret.y*cosa;
  82 + CGPointUtil.add(ret, pivot);
  83 + }
73 84 }

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.