Q: How can I syncronize the point number?

2 views
Skip to first unread message

sun...@cad.strath.ac.uk

unread,
Dec 11, 2000, 7:25:00 AM12/11/00
to
Hello,

I got a very strange thing with following code.

(array-total-size stroke-array-x) and the actual number of 'stroke-array-x'
does not match as below (I found this strange result with 'stroke-limit' in
two different setting). -----------------------------------------------------
2 > stroke-limit 33 <-- here, stroke-limit indicates actual points number. 2
> stroke-array-x #(222 222 221 218 213 206 196 180 161 141 124 112 105 104
106 115 126 141 157 178 208 211 211 210 206 202 200 197 197 198 199 200 201)
<-- here, actual number is 34 rather than 33! 2 > (array-total-size
stroke-array-x) 40 <--here, this is even bigger!
------------------------------------------------------

It seems that if I draw a stroke longer, then the gap becomes bigger. This
is strange... I don't understand why this happen... it should be same. Is
this related to the time of 'mouse-down-p' ? If so, how could I make the
number identcal between 'stroke-array-x' and (array-total-size
stroke-array-x)? Thanks for your help.

Sungwoo

;---------- (with-pen-saved (set-pen-mode view :patOr) (loop while
(mouse-down-p) for previous-x = first-x then next-x for previous-y =
first-y then next-y do (let* ((pos (view-mouse-position view))) (#_lineto
(point-h pos) (point-v pos)) (setf next-x (point-h pos)) (setf next-y
(point-v pos)) (when (or (/= previous-x next-x) (/= previous-y next-y))
(vector-push-extend next-x stroke-array-x) (vector-push-extend next-y
stroke-array-y) (vector-push-extend 0 stroke-array-z))) finally (setf
last-x next-x last-y next-y stroke-limit (array-total-size stroke-array-x)
<-- set stroke-limit same with array-total-size stroke-index (-
stroke-limit 1))))))

(with-pen-saved
(set-pen-mode view :patOr)
(loop while (mouse-down-p)
for previous-x = first-x then next-x
for previous-y = first-y then next-y
do (let* ((pos (view-mouse-position view)))
(#_lineto (point-h pos) (point-v pos))
(setf next-x (point-h pos))
(setf next-y (point-v pos))
(set-initial-region next-x next-y)
(when (or (/= previous-x next-x) (/= previous-y next-y))
(vector-push-extend next-x stroke-array-x)
(vector-push-extend next-y stroke-array-y)
(vector-push-extend 0 stroke-array-z)
(incf stroke-limit))) <--increase with point addition.
finally (setf last-x next-x
last-y next-y
stroke-index (- stroke-limit 1))))))
;---------------------------


Sent via Deja.com http://www.deja.com/
Before you buy.

Sungwoo, Lim

unread,
Dec 11, 2000, 8:58:10 AM12/11/00
to
In article <912h2p$418$1...@nnrp1.deja.com>, <sun...@cad.strath.ac.uk>

Sorry about ugly format... (I hate Netscape news service..)
I post again with different newsgroup software,
so hope this time is better. =)

I got a very strange thing with following code.

(array-total-size stroke-array-x) and the actual number of
'stroke-array-x' does not match as below (I found this strange result
with 'stroke-limit' in two different setting).
-----------------------------------------------------
2 > stroke-limit
33 <-- here, stroke-limit indicates actual points number.
2> stroke-array-x
#(222 222 221 218 213 206 196 180 161 141 124 112 105 104 106 115 126
141 157 178 208 211 211 210 206 202 200 197 197 198 199 200 201) <--
here, actual number is 34 rather than 33!
2 > (array-total-size stroke-array-x)
40 <--here, this is even bigger!
------------------------------------------------------

It seems that if I draw a stroke longer, then the gap becomes bigger.
This is strange... I don't understand why this happen... it should be
same. Is this related to the time of 'mouse-down-p' ? If so, how could
I make the number identcal between 'stroke-array-x' and
(array-total-size stroke-array-x)?

p.s During I reposting this question, I thought maybe this happened
because of the initial element-type of the array.. I mean maybe the
stroke coordinates not always be an integer (I am not sure this is
right). If system got the point as (3, 1.5) then this cannot put in
the array? Is this the reason that the difference between the
'array-total-size' and actual stroke points number?
But hyperspec told me that the element-type is automatically
adjustable...

Thanks for your help.

Sungwoo

;----------
(with-pen-saved
(set-pen-mode view :patOr)
(loop while (mouse-down-p)
for previous-x = first-x then next-x
for previous-y = first-y then next-y
do (let* ((pos (view-mouse-position view)))
(#_lineto (point-h pos) (point-v pos))
(setf next-x (point-h pos))
(setf next-y (point-v pos))
(when (or (/= previous-x next-x) (/= previous-y
next-y))
(vector-push-extend next-x stroke-array-x)
(vector-push-extend next-y stroke-array-y)
(vector-push-extend 0 stroke-array-z)))
finally (setf last-x next-x
last-y next-y
stroke-limit (array-total-size
stroke-array-x) <-- set stroke-limit same with array-total-size
stroke-index (- stroke-limit 1))))))

;-----------------
; also tried this
;-----------------

Sungwoo, Lim

unread,
Dec 11, 2000, 9:22:29 AM12/11/00
to
In article <111220001358109807%sun...@cad.strath.ac.uk>, Sungwoo, Lim
<sun...@cad.strath.ac.uk> wrote:


> p.s During I reposting this question, I thought maybe this happened
> because of the initial element-type of the array.. I mean maybe the
> stroke coordinates not always be an integer (I am not sure this is
> right). If system got the point as (3, 1.5) then this cannot put in
> the array? Is this the reason that the difference between the
> 'array-total-size' and actual stroke points number?
> But hyperspec told me that the element-type is automatically
> adjustable...

One more question is...
Is it possible to set the element-type as multi-mode?
I mean, is it possible to accept an integer and float as well?
I tried to run with float element-type, but it didn't work because the
first point was integer.
I am thinking... if the array can't accept float point such as (3, 1.5),
then why the array-total-size is bigger than actual points number...?
There must be a reason.. but can't feagure out... :(

Sungwoo

Martti Halminen

unread,
Dec 11, 2000, 9:25:03 AM12/11/00
to
"Sungwoo, Lim" wrote:

> (array-total-size stroke-array-x) and the actual number of
> 'stroke-array-x' does not match as below (I found this strange result
> with 'stroke-limit' in two different setting).
> -----------------------------------------------------
> 2 > stroke-limit
> 33 <-- here, stroke-limit indicates actual points number.
> 2> stroke-array-x
> #(222 222 221 218 213 206 196 180 161 141 124 112 105 104 106 115 126
> 141 157 178 208 211 211 210 206 202 200 197 197 198 199 200 201) <--
> here, actual number is 34 rather than 33!
> 2 > (array-total-size stroke-array-x)
> 40 <--here, this is even bigger!
> ------------------------------------------------------
>
> It seems that if I draw a stroke longer, then the gap becomes bigger.
> This is strange... I don't understand why this happen... it should be
> same. Is this related to the time of 'mouse-down-p' ? If so, how could
> I make the number identcal between 'stroke-array-x' and
> (array-total-size stroke-array-x)?

How about reading the documentation for vector-push-extend and other
stuff you are using? When the vector gets extended, it isn't necessarily
adjusted by just one item, it may expand by a larger,
implementation-dependent chunk at once. array-total-size returns the
size of the array, also including those parts of it you have not yet
used.
fill-pointer might give you more useful results in this context.

--

Sungwoo, Lim

unread,
Dec 11, 2000, 9:51:48 AM12/11/00
to
In article <3A34E3BF...@solibri.com>, Martti Halminen
<martti....@solibri.com> wrote:


> How about reading the documentation for vector-push-extend and other
> stuff you are using? When the vector gets extended, it isn't necessarily
> adjusted by just one item, it may expand by a larger,
> implementation-dependent chunk at once. array-total-size returns the
> size of the array, also including those parts of it you have not yet
> used.
> fill-pointer might give you more useful results in this context.
>
> --

Yes, (fill-pointer array) gives me exact number of points.
Thanks alot. =)

Sungwoo

Erik Naggum

unread,
Dec 11, 2000, 1:50:00 PM12/11/00
to
* "Sungwoo, Lim" <sun...@cad.strath.ac.uk>

| Is it possible to set the element-type as multi-mode?

If you don't request a specific type, you get an array that can hold
any Lisp value. It is usually a mistake to request specific types
unless you know it will have performance benefits, just like it is
usually a mistake to declare the type of arguments to functions until
you know what you _won't_ need.

#:Erik
--
"When you are having a bad day and it seems like everybody is trying
to piss you off, remember that it takes 42 muscles to produce a
frown, but only 4 muscles to work the trigger of a good sniper rifle."
-- Unknown

Sungwoo, Lim

unread,
Dec 11, 2000, 4:37:05 PM12/11/00
to
In article <31855494...@naggum.net>, Erik Naggum <er...@naggum.net>
wrote:

> * "Sungwoo, Lim" <sun...@cad.strath.ac.uk>
> | Is it possible to set the element-type as multi-mode?
>
> If you don't request a specific type, you get an array that can hold
> any Lisp value. It is usually a mistake to request specific types
> unless you know it will have performance benefits, just like it is
> usually a mistake to declare the type of arguments to functions until
> you know what you _won't_ need.
>
> #:Erik

Thanks, =)

Sungwoo

Reply all
Reply to author
Forward
0 new messages