Questions tagged [cgpoint]

CGPoint is a structure from Apple's Core Graphics framework. It is used to represent a point in two dimensions.

CGPoint is a C struct that contains information about the location of a point in two dimensions.

Fields:

  • x: The X location of the point
  • y: The Y location of the point
509 questions
3
votes
3 answers

iOS/Mac OS: Saving and comparing CGPoints/NSPoints in Arrays

My intention is to compare CGPoints or CGPoint values (and as the app is also for Mac OS NSPoints or NSPoint values) of several moving objects to detect if the objects have the same position. My first solution to this was to fast enumerate an array…
FrankZp
  • 2,022
  • 3
  • 28
  • 41
3
votes
1 answer

Why does CGPointEqualToPoint simply perform (p.x == p.x && p.y == p.y)?

Since comparing floats is such a difficult and debated issue I was surprised to see that CGPointEqualToPoint and the other CG comparison methods simply do this: CG_INLINE bool __CGPointEqualToPoint(CGPoint point1, CGPoint point2) { return point1.x…
CodeSmile
  • 64,284
  • 20
  • 132
  • 217
3
votes
2 answers

NSPredicate filter class by CGPoint

I have that class : @interface Field : NSObject @property CGPoint fieldCoordinates; @property CGPoint ballCoordinates; @end and i Try filter NSArray of object of this class : NSPredicate * y1 = [NSPredicate predicateWithFormat:@"ballCoordinates.y…
netmajor
  • 6,507
  • 14
  • 68
  • 100
3
votes
2 answers

Create an array of CGPoints by pairing values from two different NSArrays

How to create an array of CGPoints by pairing values from two different NSArrays in objective-c? Lets say I have an Array "A" with the values: 0, 1, 2, 3, 4 And I also have an Array "B" with the values: 21, 30, 33, 35, 31 I would like to create…
Juan Andres
  • 433
  • 7
  • 19
3
votes
1 answer

Get the distance between two CGPoints in a UIImageView nested in a UIScrollView

CGRect screenSize = [[UIScreen mainScreen]bounds]; CGFloat screenWidth = screenSize.size.width; CGRect visibleRect; visibleRect.origin = scrollView.contentOffset; visibleRect.size = imageView.frame.size; CGPoint midPoint =…
avs
  • 65
  • 8
3
votes
2 answers

How come CGFloat is making up significant digits?

Possible Duplicate: CGFloat addition bug? I have a CGPoint (which is just a struct around two CGFloats). Can someone explain to me how these two lines of code: player.position = CGPointMake(player.position.x + 12.8f, player.position.y +…
InkGolem
  • 2,662
  • 1
  • 15
  • 22
3
votes
1 answer

how to give a CGPoint line unique colors Xcode

A very simple XCode iPhone app. Blank screen, draw lines, each line is to have a unique colour given via a random number gen. I have the code to give me random colours, but I cannot get the lines to retain the colour individually. Any time the…
ko1984
  • 41
  • 2
3
votes
2 answers

CATransform3D equivavelent to CGPointApplyAffineTransform and friends

How can I write the CATransform3D equivalent to CGPoint CGPointApplyAffineTransform(CGPoint point, CGAffineTransform t) CGSize CGSizeApplyAffineTransform(CGSize size, CGAffineTransform t); CGRect CGRectApplyAffineTransform(CGRect rect,…
hfossli
  • 22,616
  • 10
  • 116
  • 130
3
votes
1 answer

Storing CGPoints in NSMutableArray and Sqlite

I would like to store the points whenever touchesMoved is called. So far everything is working fine. However what I want to do is to create a "new" array every time touchesMoved is called. For example, once the touch ended the array of points are…
Anna Fortuna
  • 1,071
  • 2
  • 17
  • 33
3
votes
1 answer

CGPoint rotation changes distance from origin

I want to rotate a CGPoint(red rect) around another CGPoint(blue rect) but it changes distance from the origin(blue rect)...when i give 270 in angle it creates the point right above the origin but when i give 90 as angle value it comes down the…
Dani
  • 73
  • 1
  • 11
3
votes
3 answers

Distance between two rectangles

How can I find the distance between two rectangles? Intersects should return 0 in distance.
thedarkside ofthemoon
  • 2,251
  • 6
  • 31
  • 48
3
votes
2 answers

iOS: Sorting NSArray of NSValue wrapping CGPoint

Qeustion: Pretty much as stated in the title. I looked over the internet but cannot find anything that is easy to understand. I have NSArray that contains many NSValue. Those NSValue each hold a CGPoint. I want to sort them by x then by y…
Byte
  • 2,920
  • 3
  • 33
  • 55
2
votes
1 answer

Objective-C rectangular CGPoint to polar CGPoint

I found the equations to convert an X,Y into radius and angle: x = r*Cos(Q) y = r*Sin(Q) r= sqrt(x*x + y*y) Q = tan^-1(y/x) My problem is that I dont remember what is the syntax for the tan^-1 in objective C. I do not want to get things wrong.…
Alex Stone
  • 46,408
  • 55
  • 231
  • 407
2
votes
2 answers

Converting NSPoint to CGPoint using NSPointToCGPoint

How difficult can it be to access x and y coordinates from NSPoint...Can't believe it. I get an NSPoint from following call: var mouseLoc = [NSEvent .mouseLocation] I need to access x and y coordinates. NSPoint does not offer a getter like CGPoint.…
user688262
  • 171
  • 11
2
votes
1 answer

Points Versus Pixels ios

I have uiview , that I zoom in and out in it I associate it with pinchRecognizerMeasure using pinchRecognizerMeasure = [[UIPinchGestureRecognizer alloc] initWithTarget:self action:@selector(MeasureAndDraw:)]; [pinchRecognizerMeasure…
AMH
  • 6,363
  • 27
  • 84
  • 135