linecirc
Find intersection of line and circle in Cartesian coordinates
Description
Examples
Find Intersection of Line and Circle
Find the intersection of the line and a circle with its center at (3, 4) and a radius of 5.
[xout,yout] = linecirc(2,-1,3,4,5)
xout = 1×2
4.8271 0.3729
yout = 1×2
8.6542 -0.2542
Find Intersection of Vertical Line and Circle
Find the intersection of the line and a circle with its center at (3, 4) and a radius of 5.
[xout,yout] = linecirc(Inf,-1,3,4,5)
xout = 1×2
-1 -1
yout = 1×2
7 1
Input Arguments
slope
— Slope of line
numeric scalar | Inf
Slope of the line, specified as a numeric scalar or Inf
. Specify
Inf
when the line is vertical.
intercpt
— Intercept of line
numeric scalar
Intercept of the line, specified as a numeric scalar.
When
slope
is a numeric scalar, this argument is the y-intercept of the line.When
slope
isInf
, this argument is the x-intercept of the line.
centerx
— x-coordinate of center of circle
numeric scalar
x-coordinate of the center of the circle, specified as a numeric scalar.
centery
— y-coordinate of center of circle
numeric scalar
y-coordinate of the center of the circle, specified as a numeric scalar.
radius
— Radius of circle
positive scalar
Radius of the circle, specified as a positive scalar.
Output Arguments
xout
— x-coordinates of intersections
two-element vector
x-coordinates of the intersections, returned as a two-element vector.
When the line is tangent to the circle, the elements of the vector are equal.
When the line does not intersect the circle, both elements are
NaN
.
yout
— y-coordinates of intersections
two-element vector
y-coordinates of the intersections, returned as a two-element vector.
When the line is tangent to the circle, the elements of the vector are equal.
When the line does not intersect the circle, both elements are
NaN
.
Version History
Introduced before R2006a
Abrir ejemplo
Tiene una versión modificada de este ejemplo. ¿Desea abrir este ejemplo con sus modificaciones?
Comando de MATLAB
Ha hecho clic en un enlace que corresponde a este comando de MATLAB:
Ejecute el comando introduciéndolo en la ventana de comandos de MATLAB. Los navegadores web no admiten comandos de MATLAB.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)