I'm writing a code to find the intersection points of two circles.
Show older comments
The circirc function is giving me assert problems, so is the assert function.
I will not link the whole question, since that would be defeating the purpose of actually working on the code and learning.
The question will get more complicated deep through, but the starting point is finding the points of intesection of two circles of variable centers and radii.
PS. I'm a uni student and MATLAB is not fun at all for me. The code might look terribly hideous and I apologize for that. Can someone give tips to start enjoying MATLAB more and have a faster and more effective way of learning all its functionalities. Thanks in advance.
PPS. This code is due to next week and I would really appreciate a quick reply! Thanks again <3
Here is the code:
%DEFINE INPUT PARAMETERS%
syms x y
A = [x y];
B = [x y];
C = [x y];
D = [x y];
AB = norm(A-B);
CD = norm(C-D);
AC = norm(A-C);
%ASSUMPTIONS%
assume(x, 'real');
assume(y, 'real');
assume(AB > 0 );
assume(CD > 0 );
assume(AC > 0 );
%FINDING INTERSECTION%
assert(AB > 0 && CD > 0); %what is happening here?%
[xint, yint] = circcirc(A(1),A(2),AB,C(1),C(2),CD);
%Error using assert
Assertion failed.
Error in problem_geogebra1 (line 61)
assert(AB > 0 && CD > 0);%
E = [xint(1), yint(1)];
F = [xint(2), yint(2)];
5 Comments
Ali Abdel Sater
on 15 Dec 2022
Moved: John D'Errico
on 16 Dec 2022
Fifteen12
on 16 Dec 2022
Moved: John D'Errico
on 16 Dec 2022
Glad you found an answer to your question. In defense of those "mvps" (of whom I am not one), most of them work without being paid by MATLAB, answering questions here out of a genuine desire to help out, rather than any obligation. It's good to remember that they're volunteers, just trying to help out. It's good to hear more about another resource in ChatGPT though, especially if there's no one available to help immediately.
As for the question, I've found most responders happy to help answer questions especially for university students. I'm still not sure what your actual question was though!
Ali Abdel Sater
on 20 Dec 2022
Image Analyst
on 20 Dec 2022
Can you show a diagram? It might help. And why can't you just set the two equations equal to each other?
(x-xc1)^2 + (y-yc1)^2 = r1^2
(x-xc2)^2 + (y-yc2)^2 = r2^2
Two equations, two unknowns
Ali Abdel Sater
on 20 Dec 2022
Edited: Ali Abdel Sater
on 20 Dec 2022
Answers (2)
Fifteen12
on 8 Dec 2022
0 votes
You can find the documentation for assert here: https://www.mathworks.com/help/sltest/ref/assert.html
Assert stops your simulation if the expression passed to it is false. In this case, the expression is making sure that the line AB and the line CD are both positive. I am curious how it failed, to my knowledge norm should always return a positive number, though perhaps we're just missing some pieces of the problem (as you stated) where AB and CD were adjusted.
As for enjoying MATLAB, the thrill is in the journey. Just like with learning a new language, the first couple of steps are the most frustrating while you learn the basics. Don't give up just because it's hard at the start!
3 Comments
Ali Abdel Sater
on 8 Dec 2022
Fifteen12
on 9 Dec 2022
I'm actually not sure what your question is, are you having trouble understanding assert? Or with an error being thrown by assert?
Ali Abdel Sater
on 9 Dec 2022
You had a problem in the use of syms here, causing an error.
syms x y
A = [x y];
B = [x y];
C = [x y];
D = [x y];
AB = norm(A-B);
CD = norm(C-D);
AC = norm(A-C);
%ASSUMPTIONS%
assume(x, 'real');
assume(y, 'real');
assume(AB > 0 );
assume(CD > 0 );
assume(AC > 0 );
The warnings are just warnings, but they tell something useful, IF you look at them carefully and you think about the value of those variables.
What is AB here? CD?
AB
CD
Do you see they are identically zero? Now, let me perform two sets of asserts...
%FINDING INTERSECTION%
assert(AB >= 0 && CD >= 0); %what is happening here?%
No error is generated.
assert(AB > 0 && CD > 0); %what is happening here?%
So AB and CD are both identically zero. That means the assertion must fail, because you were asserting these parameters must be POSITIVE. Had you allowed zero in the assertion, it would not have caused an assertion failure.
As far as receiving an answer in a more timely way, we are not paid to answer questions immediately. We are here by choice, and are not paid at all. If someone sees your question when you want an answer, and they know the answer, then you will get an answer quickly. Sorry, but that is how a volunteer forum works. And if you post a question at an inopportune time when maybe nobody is awake or those who could answer are having dinner, then you get an answer when someone is able to answer and not before.
1 Comment
Ali Abdel Sater
on 20 Dec 2022
Edited: Ali Abdel Sater
on 20 Dec 2022
Categories
Find more on Lengths and Angles in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!