[Xy-pic] Colour only a pice of curve

Ross Moore ross.moore at mq.edu.au
Wed Sep 2 03:46:18 CEST 2015


Hello Diego,

On 01/09/2015, at 6:35 PM, Diego wrote:

> Hi,
> in reference to the following piece of code, I'm trying to paint the curve
> from 0 to 1 in a different colour but only between the intersection points
> "i1" and "i2".
> 
> %----
> \begin{xy}
> (0,0)*{0}="o";<5mm,0mm>:<0mm,5mm>::,
> (5,8)*{1}="b", (-5,0)="c", (5,0)="d",
> 
> (-1.5,2.5)="c1", (1.5,2.5)="c2",
> "c";"d" **\crv{"c1"&"c2"},
> 
> (-4,10)="d1", (4,10)="d2",
> "c";"d" **\crv{"d1"&"d2"},
> 
> (0,5)="q1", (2,9)="q2",
> "o";"b" **\crv{"q1"&"q2"}
> ?!{"c";"d" **\crv{~**{}"c1"&"c2"}}*@{>}="i1"
> ?!{"c";"d" **\crv{~**{}"d1"&"d2"}}*@{<}="i2",

I think you are trying to find the intersection point of 2 spline curves.

We never wrote the method to do this in Xy-pic.
So you cannot get your points "i1" and "i2" to be calculated
automatically.

However, you can do a bit of trial-and-error to determine
the approximate value of the spline parameter (between 0 & 1)
for these, in a particular instance.

> \end{xy}
> %----
> [image: Immagine incorporata 2]
> At the moment my workaround is to crate three \crv:
> - from 0 to "i1";
> - from "i1" to "i2" using the syntax "i1";"i2" **[colour]\crv{..&..};
> - from "i2" to 1.
> 
> With a software like Geogebra I can find the rights coordinates of the
> control points so that the result seems to be only one Bezier curve, but
> it's a lot of work.
> 
> Is there a more simple way to achieve the same result?

This is doing what I think you want.


\pdfoutput 0 
\documentclass{article}
\usepackage[ps,dvips,all,frame,color]{xy}
\begin{document}
\UsePSspecials{}
\begin{xy}
(0,0)*+!R{0}="o";<5mm,0mm>:<0mm,5mm>::,
(5,8)*+!L{1}="b", (-5,0)="c", (5,0)="d",
%
(-1.5,2.5)="c1", (1.5,2.5)="c2",
(-4,10)="d1", (4,10)="d2",
"c";"d" **\crv{"c1"&"c2"},
"c";"d" **\crv{"d1"&"d2"},
(0,5)="q1", (2,9)="q2",
%
"o";"b" **i\crv{"q1"&"q2"} % after trial-and-error, set it invisibly
?(.129)*[red]@{x}="i1", %  .129  found by trial-and-error
?(.581)*[red]@{x}="i2", %  .581  found by trial-and-error
%?!{"c";"d" **\crv{"c1"&"c2"}}*@{>}="i1"
%?!{"c";"d" **\crv{"d1"&"d2"}}*@{<}="i2",
%
"b"."i2"*\frm{.};
"o"."i1"*\frm{.}; **[red]\crv{"q1"&"q2"},
"o";"b"."i1", **[blue]\crv{"q1"&"q2"},
"o"."i2";"b", **[blue]\crv{"q1"&"q2"},
%
\end{xy}
\end{document}

-------------- next part --------------
A non-text attachment was scrubbed...
Name: texshop_image.jpeg
Type: image/jpeg
Size: 62830 bytes
Desc: not available
URL: <http://tug.org/pipermail/xy-pic/attachments/20150902/49237e60/attachment-0001.jpeg>
-------------- next part --------------



> 
> Thanks
> 
> -- 
> Diego


Cheers,

	Ross





More information about the xy-pic mailing list