Verify if a section of an arc intersects with a circular shape

I'm currently working on determining the intersection between an arc and a circle.

I have successfully identified intersections when I treat the arc as a complete circle using the code snippet provided. However, I am facing difficulty in finding a solution to determine the intersection between an actual arc and a circle (or two arcs). The circle data includes center coordinates and radius, while the arc data consists of center coordinates, start point, end point, angle from center to points, start angle, and end angle.

//Calculate distance between two circles
var d = this.center.distanceTo(cursor.center);

// Check for Intersections
if (d > (this.radius + cursor.radius)) {
    //Circles do not intersect
    return false;
} else if (d < this.radius - cursor.radius) {
    // No Solution. One circle is contained within the other
    return false;
} else {
    // Circles intersect
    return true;
}

My goal is to determine the result of the intersection between the arc and circle. Additionally, it would be helpful to identify the coordinates of these intersections, although it is not necessary at this point.

I have reviewed source, but struggle to interpret it into a code formula.

Answer №1

The midpoint of your circular arc contains an angle that directs towards the adjacent circle. Identify the angle closest to it within the arc and project it to the corresponding point on the arc. In case this point falls within the circle, it confirms that your arc overlaps with the circle.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

How can I transfer a PHP variable into a JavaScript variable nested within another PHP variable

After my php/html script generates the image, I am looking to display it without needing to reload the page. I currently call a javascript function within the PHP code to change the image. However, I am unsure how to pass the new image name to this javasc ...

Changing knockoutJS foreach binding dynamically

I have a list of arrays known as table#1, table#2, ... table#10 and I want to be able to click on a table number and display the list items of that table in a panel. Here is a snippet of the code: The HTML part works fine. The only issue lies in this li ...

Ensure that Google Tag Manager (GTM) delays the pageview until the SPA URL title is available

I'm dealing with a React SPA that manages all the URL titles on the frontend, so the historyChange event registered on GTM captures the visited URLs along with their titles correctly. However, I've noticed that on the initial load of the SPA, su ...

Is there a way to access the original query string without it being automatically altered by the browser?

I'm currently encountering an issue with query strings. When I send an activation link via email, the link contains a query string including a user activation token. Here's an example of the link: http://localhost:3000/#/activation?activation_cod ...

Deleting a hyperlink within a content-editable area

Presently, I am in the process of working on a straightforward project where users can format text using contenteditable. I have successfully implemented a feature that allows users to add hyperlinks to selected text by clicking on the "Create Link" button ...

Encountering a SassError while trying to create unique themes with Angular Materials

I'm currently in the process of designing a unique theme for Angular Materials by following the instructions provided in this guide:https://material.angular.io/guide/theming#defining-a-custom-theme However, I've encountered an issue while attemp ...

Is it possible to create a Three.js animation with a see-through background?

I have an HTML5 video with a greenscreen effect that I want to display on a plane using a video texture in Three.js. I attempted to use separate video textures for the main video and the alpha channel, but encountered synchronization issues. From what I u ...

How to Convert Irregular Timestamps in Node.js?

Currently, I am utilizing an API to retrieve information from Google News and proceed to save the data in Firestore. The challenge lies in the fact that the API delivers timestamps in various formats which are not uniform. For example: "1 Day Ago", "June ...

Prevent the mouseup event in jQuery when the mouse has previously been moved

I have a div with a row of span buttons displayed horizontally. Since there are too many buttons to fit on the screen, I want to enable the user to click and drag the entire row of buttons. However, my challenge is to ensure that the button's mouseup ...

The function `map` cannot be applied to `this.state.[object]`

It seems like I might be overlooking a simple mistake, but I keep encountering this.state.iata.map is not a function , even though I have bound the context to all functions where I need to access that state. Additionally, the iata state is an array, s ...

The autocomplete feature is situated quite a bit lower than the input box

One issue I am facing in my MVC Razor page is with the autocomplete functionality. When the textbox is first used, the autocomplete results appear below the textbox (as shown in this image), but on subsequent uses, it appears correctly directly below the t ...

The code functions perfectly on the local server, but encounters issues on the hostinger hosting service - after dedicating 3 days to researching online and numerous unsuccessful attempts

[SCREEN SHOT ERROR 500 APPEARS EVEN AFTER FIXING THE PATH IN AJAX CODE] Uncertain if the issue lies in the ajax call or the path of resource files (jquery) HEADER, I ATTEMPTED TO USE MVC WHERE THE INDEX PAGE CONTAINS PATHS TO ALL PAGES, HEADER, FOOTER, CO ...

Encountering a display issue within a port using Express

Recently, I enrolled in an advanced ExpressJS course. While exploring the course website, I stumbled upon the "hello world" section. Intrigued, I decided to copy and paste the code provided below: const express = require('express') const app = ex ...

React Forms: Dynamically Updating the User Interface using WithFormik() and Axios GET Response

I've been using withFormik() to create a form for my Gatsby application. Currently, I am implementing a GET request using axios within the handleSubmit() function of withFormik(). Once I receive the response, I want to update it on the UI immediately ...

How do I send events between router view components in Vue.js?

I'm currently developing an e-commerce platform utilizing vue.js with a backend API. The root component is named Main.vue, consisting of a navigation section using router-link and a main content area displayed by router-view. Within the Cart.vue rout ...

Mastering the art of mocking modules with both a constructor and a function using Jest

I'm a Jest newbie and I've hit a roadblock trying to mock a module that includes both a Class ("Client") and a function ("getCreds"). The Class Client has a method called Login. Here's the code snippet I want to test: import * as sm from &ap ...

Promise - rapidly access data from a function that resolves a Promise

Could someone suggest a technique for instantly extracting data from a function that returns a Promise? For example, in my simplified scenario, I have an AJAX preloader like this: loadPage("index.html").then(displayPage); If the page being loaded is lar ...

What is the best way to combine two vertex positions using a distance-based blending technique relative to the camera's position?

My goal is to achieve a smooth transition between two different vertex positions based on the distance from the camera. Specifically, I aim to create a visual effect that seamlessly shifts between a horizontal plane near the camera and a vertical plane in ...

`How can you effectively simulate class modules in Jest?`

Working with the amplitude module requires me to start by creating an instance of a class and then use its methods. Here's the initial code snippet: var Amplitude = require('amplitude'); const amplitude = new Amplitude(process.env.amplitude ...

Troubleshooting: Missing Headers in AngularJS HTTP Requests

When I make a request using AngularJS like this: var config = { headers: { 'Authorization': 'somehash', 'Content-Type': 'application/json; charset=UTF-8' } }; $http.get('htt ...