Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7633369
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T06:51:53+00:00 2026-05-31T06:51:53+00:00

I have a game where you have specks and connectors. I make a UIImageView

  • 0

I have a game where you have “specks” and “connectors”.

I make a UIImageView that connects two “specks”… but as you can see (if the picture works), when the specks are almost on top of each other, like on the left, it doesn’t work. This is my code… and I was wondering how you would make the rotation more accurate in that sort of situation.

UIImageView *connector = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"RedConnector.png"]];
        connector.contentMode = UIViewContentModeScaleToFill;
        connector.hidden = NO;
        connector.alpha = 1;

        connector.frame = CGRectMake(0, 0, [self DistanceBetweenPoints:speck1.center :speck2.center], 7);
        connector.center = CGPointMake((speck1.center.x + speck2.center.x)/2, (speck1.center.y + speck2.center.y)/2);
//This is where the prob is:
        connector.transform = CGAffineTransformMakeRotation(tanh((speck2.center.y - speck1.center.y)/(speck2.center.x - speck1.center.x)) );
        [Connectors addObject:connector];
        [self.view addSubview:connector];

“DistanceBetweenPoints” is not the problem. That works fine. Also, I know the center AND the frame is sort of redundant– I’ll work that out later. Third of all, I have made sure that two specks are never directly on top of each other (to never divide by zero). Last of all, I STILL WANT THESE TO BE UIIMAGEVIEWS!! So I can change the image and animate them so it looks like electricity flowing from speck to speck.

If anybody could show me how to make the rotation more accurate, it would be greatly appreciated. Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T06:51:55+00:00Added an answer on May 31, 2026 at 6:51 am

    You should use atan2(y,x), not tanh(y/x). That is, you want the arctangent, not the hyperbolic tangent.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We have a game that is very close to being released, but we have
I have a game in the works in Cocos2d. I have enemies that spawn
I have tried google it but I can't find one that looks legit. I
I have game objects in an array collection, but they can be different classes.
I have a game that currently runs under Windows and Mac OS X and
I have a game engine that uses OpenGL for display. I coded a small
I have a game application that I will be running in a web browser
I am in a situation where I have game objects that have a virtual
I have a game tree that is too big to walk in its entirety.
I have a game with two rootViewControllers - one for the Menu and the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.